code_junkie

How to recognize a path inside a string

Nov 12th, 2011
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.35 KB | None | 0 0
  1. bool isPath = System.IO.Path.GetDirectoryName(@"C:MyFolderSomeFile.exe -i -d") != String.Empty;
  2. if (isPath)
  3. {
  4. Console.WriteLine("The string contains a path");
  5. }
  6.  
  7. C:My FolderSome File.exe -i -d
  8. =>
  9. C:My FolderSome File.exe -i -d (no, although it might exist!)
  10. C:My FolderSome File.exe -i (no)
  11. C:My FolderSome File.exe (yes => That's this one)
Add Comment
Please, Sign In to add comment