Check the given path is of a file or a directory

Madhu.b.rokkam
Posted by Madhu.b.rokkam under C# category on | Points: 40 | Views : 2349
string path = @"C:\DotNetFunda";
if (File.Exists(path))
{
Console.WriteLine("{0} is a file path", path);
}
else if (Directory.Exists(path))
{
Console.WriteLine("{0} is a directory path", path);
}

Comments or Responses

Posted by: Tripati.patro on: 2/22/2011 Level:Starter | Status: [Member] | Points: 10
Good and simple code.

Login to post response