C# FileNotFoundException.Equals的代码示例
通过代码示例来学习C# FileNotFoundException.Equals方法
通过代码示例来学习编程是非常高效的。
1. 代码示例提供了一个具体而直观的学习环境,使初学者能够立即看到编程概念和语法的实际应用。
2. 通过分析和模仿现有的代码实例,初学者可以更好地理解编程逻辑和算法的工作原理。
3. 代码实例往往涵盖了多种编程技巧和最佳实践,通过学习和模仿这些实例,学习者可以逐步掌握如何编写高效、可读性强和可维护的代码。这对于初学者来说,是一种快速提升编程水平的有效途径。
FileNotFoundException.Equals是C#的System.IO命名空间下中的一个方法, 小编为大家找了一些网络大拿们常见的代码示例,源码中的FileNotFoundException.Equals() 已经帮大家高亮显示了,大家可以重点学习FileNotFoundException.Equals() 方法的写法,从而快速掌握该方法的应用。
FileNotFoundException.Equals的代码示例1 - TryPrepareFolderForCallbacks()
using System.IO; public bool TryPrepareFolderForCallbacks(string folderPath, out string error, out Exception exception) { exception = null; try { return this.TryPrepareFolderForCallbacksImpl(folderPath, out error); } catch (FileNotFoundException e) { exception = e; if (e.FileName.Equals(ProjFSManagedLibFileName, GVFSPlatform.Instance.Constants.PathComparison)) { error = $"Failed to load {ProjFSManagedLibFileName}. Ensure that ProjFS is installed and enabled"; } else { error = $"FileNotFoundException while trying to prepare \"{folderPath}\" for callbacks: {e.Message}"; } return false; } catch (Exception e) { exception = e; error = $"Exception while trying to prepare \"{folderPath}\" for callbacks: {e.Message}"; return false; } }
开发者ID:microsoft,项目名称:VFSForGit,代码行数:31,代码来源:ProjFSFilter.cs
在TryPrepareFolderForCallbacks()方法中,FileNotFoundException的代码示例类中的Equals的代码示例方法一共出现了1次, 见黄色背景高亮显示的地方,欢迎大家点赞
FileNotFoundException.Equals的代码示例2 - GetCodec()
using System.IO; ///
/// Returns a fully initialized /// Filename of the specified file. ///instance which is able to decode the specified file. If the /// specified file can not be decoded, this method throws an . /// Fully initialized ///instance which is able to decode the specified file. The codec of the specified file is not supported. public IWaveSource GetCodec(string filename) { if(String.IsNullOrEmpty(filename)) throw new ArgumentNullException("filename"); if (!File.Exists(filename)) throw new FileNotFoundException("File not found.", filename); string extension = Path.GetExtension(filename).Remove(0, 1); //get the extension without the "dot". IWaveSource source = null; if (File.Exists(filename)) { Stream stream = File.OpenRead(filename); try { foreach (var codecEntry in _codecs) { try { if ( codecEntry.Value.FileExtensions.Any( x => x.Equals(extension, StringComparison.OrdinalIgnoreCase))) { source = codecEntry.Value.GetCodecAction(stream); if (source != null) break; } } catch (Exception ex) { Debug.WriteLine(ex.ToString()); } } } finally { if (source == null) { stream.Dispose(); } else { source = new DisposeFileStreamSource(source, stream); } } } if (source != null) return source; return Default(filename); }
开发者ID:filoe,项目名称:cscore,代码行数:62,代码来源:CodecFactory.cs
在GetCodec()方法中,FileNotFoundException的代码示例类中的Equals的代码示例方法一共出现了1次, 见黄色背景高亮显示的地方,欢迎大家点赞
本文中的FileNotFoundException.Equals方法示例由csref.cn整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。