C# Path.GetInvalidPathChars的代码示例
通过代码示例来学习C# Path.GetInvalidPathChars方法
通过代码示例来学习编程是非常高效的。
1. 代码示例提供了一个具体而直观的学习环境,使初学者能够立即看到编程概念和语法的实际应用。
2. 通过分析和模仿现有的代码实例,初学者可以更好地理解编程逻辑和算法的工作原理。
3. 代码实例往往涵盖了多种编程技巧和最佳实践,通过学习和模仿这些实例,学习者可以逐步掌握如何编写高效、可读性强和可维护的代码。这对于初学者来说,是一种快速提升编程水平的有效途径。
Path.GetInvalidPathChars是C#的System.IO命名空间下中的一个方法, 小编为大家找了一些网络大拿们常见的代码示例,源码中的Path.GetInvalidPathChars() 已经帮大家高亮显示了,大家可以重点学习Path.GetInvalidPathChars() 方法的写法,从而快速掌握该方法的应用。
Path.GetInvalidPathChars的代码示例1 - IsFolderValid()
using System.IO; private bool IsFolderValid(string folderPath) { if (folderPath == GVFSConstants.DotGit.Root || folderPath.StartsWith(GVFSConstants.DotGit.Root + Path.DirectorySeparatorChar) || folderPath.StartsWith(".." + Path.DirectorySeparatorChar) || folderPath.Contains(Path.DirectorySeparatorChar + ".." + Path.DirectorySeparatorChar) || Path.GetInvalidPathChars().Any(invalidChar => folderPath.Contains(invalidChar))) { return false; } return true; }
开发者ID:microsoft,项目名称:VFSForGit,代码行数:15,代码来源:DehydrateVerb.cs
在IsFolderValid()方法中,Path的代码示例类中的GetInvalidPathChars的代码示例方法一共出现了1次, 见黄色背景高亮显示的地方,欢迎大家点赞
Path.GetInvalidPathChars的代码示例2 - GetCachePath()
using System.IO; #endif #if NET45 || NETSTANDARD1_3 || NETSTANDARD1_6 ///
/// Gets an HTML document from an Internet resource and saves it to the specified file. Understands Proxies /// /// The requested URL, such as "http://Myserver/Mypath/Myfile.asp". /// The location of the file where you want to save the document. /// /// The HTTP method used to open the connection, such as GET, POST, PUT, or PROPFIND. /// public void Get(string url, string path, IWebProxy proxy, ICredentials credentials, string method) { Uri uri = new Uri(url); #if !(NETSTANDARD1_3 || NETSTANDARD1_6) if ((uri.Scheme == Uri.UriSchemeHttps) || (uri.Scheme == Uri.UriSchemeHttp)) #else // TODO: Check if UriSchemeHttps is still internal in NETSTANDARD 2.0 if ((uri.Scheme == "https") || (uri.Scheme == "http")) #endif { Get(uri, method, path, null, proxy, credentials); } else { throw new HtmlWebException("Unsupported uri scheme: '" + uri.Scheme + "'."); } } #endif ////// Gets the cache file path for a specified url. /// /// The url fo which to retrieve the cache path. May not be null. ///The cache file path. public string GetCachePath(Uri uri) { if (uri == null) { throw new ArgumentNullException("uri"); } if (!UsingCache) { throw new HtmlWebException("Cache is not enabled. Set UsingCache to true first."); } string cachePath; if (uri.AbsolutePath == "/") { cachePath = Path.Combine(_cachePath, ".htm"); } else { string absolutePathWithoutBadChar = uri.AbsolutePath; string invalid = new string(Path.GetInvalidFileNameChars()) + new string(Path.GetInvalidPathChars()); foreach (char c in invalid) { absolutePathWithoutBadChar = absolutePathWithoutBadChar.Replace(c.ToString(), ""); } if (uri.AbsolutePath[uri.AbsolutePath.Length - 1] == Path.AltDirectorySeparatorChar) { cachePath = Path.Combine(_cachePath, (uri.Host + absolutePathWithoutBadChar.TrimEnd(Path.AltDirectorySeparatorChar)).Replace('/', '\\') + ".htm"); } else { cachePath = Path.Combine(_cachePath, (uri.Host + absolutePathWithoutBadChar.Replace('/', '\\'))); } } return cachePath; }
开发者ID:zzzprojects,项目名称:html-agility-pack,代码行数:79,代码来源:HtmlWeb.cs
在GetCachePath()方法中,Path的代码示例类中的GetInvalidPathChars的代码示例方法一共出现了1次, 见黄色背景高亮显示的地方,欢迎大家点赞
本文中的Path.GetInvalidPathChars方法示例由csref.cn整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。