1

I have a string var (path) that represents a path:

printfn "Please enter a path"
let path = System.Console.ReadLine()

Is there a way of knowing wheter this path is for a directory or a regular file?

ildjarn
  • 62,044
  • 9
  • 127
  • 211
cookya
  • 3,019
  • 7
  • 26
  • 37
  • Duplicate: http://stackoverflow.com/questions/439447/net-how-to-check-if-path-is-a-file-and-not-a-directory; http://stackoverflow.com/questions/1395205/better-way-to-check-if-path-is-a-file-or-a-directory-c-net – Daniel Jun 21 '12 at 21:07

1 Answers1

2

Use Directory.Exists(path) and File.Exists(path).

pad
  • 41,040
  • 7
  • 92
  • 166
  • does File.Exists(path) just check if any kind of file (including a directory) exists in this path, or only regular files? – cookya Jun 21 '12 at 19:07
  • I think `File.Exists` works for regular files only. – pad Jun 21 '12 at 19:17