How can I determine if a string is a local folder string or a network string?
问题 How can I determine in c# if a string is a local folder string or a network string besides regular expression? For example: I have a string which can be "c:\a" or "\\foldera\folderb" 回答1: new Uri(mypath).IsUnc 回答2: I think the full answer to this question is to include usage of the DriveInfo.DriveType property. public static bool IsNetworkPath(string path) { if (!path.StartsWith(@"/") && !path.StartsWith(@"\")) { string rootPath = System.IO.Path.GetPathRoot(path); // get drive's letter System