CSharp examples for System.IO:File Path
Gets whether the specified path is a valid absolute file path.
using System.Threading; using System.Text.RegularExpressions; using System.Text; using System.Security.Cryptography; using System.Net; using System.Linq; using System.Globalization; using System.Collections.Generic; using System;//from ww w .j a v a2 s . c om public class Main{ /// <summary> /// Gets whether the specified path is a valid absolute file path. /// </summary> /// <param name="path">Any path. OK if null or empty.</param> static public bool IsValidPath(string path) { Regex r = new Regex(@"^(([a-zA-Z]\:)|(\\))(\\{1}|((\\{1})[^\\]([^/:*?<>""|]*))+)$"); return r.IsMatch(path); } }