On 5 Feb, 12:08, "xxxx" <xxxxl...@gmail.comwrote:
hi,
i was wondering if u can help with the following
how can i figure out that a given path, represents a file or folder
Console.WriteLine(System.IO.File.Exists(@"C:
\AUTOEXEC.BAT").ToString()); //true
Console.WriteLine(System.IO.Directory.Exists(@"C:
\WINDOWS").ToString()); //true
Console.WriteLine(System.IO.Directory.Exists(@"C:
\AUTOEXEC.BAT").ToString()); //false
Console.WriteLine(System.IO.File.Exists(@"C:\WINDO WS").ToString()); //
false
So check if the file exists, and if not, check if the directory exists
(Important to add that step, don't just assume as the path may be
invalid).
Incidently, Console.WriteLine(System.IO.Directory.Exists(@"C:\ WINDOWS
\").ToString());
will work as well, so no need to worry about trailing \ characters.