In a C# 2008 application, I have a check to make certain the directory file does not exist. if it does not exist, then I want to display an error message.
Here is the code I have so far:
string strFullpath = '"C:\\Data\\IFiles"
if (!Directory.Exists(strFullpath))
{
display error message
}
else
{
}
The code is not correct somehow. The directory file does exist. Thus can you tell me how to change this code to really check if the directory file does exist?
Loading
Upamanyu Roy ChoudhuryPosted Feb 20, 2013, 12:56 PM
I think your syntax is right however the path is wrong , please follow the the way below
if (!Directory.Exists(@"C:/test/" + foldername)
Directory.CreateDirectory(@"C:/test/" + foldername);
You can check by the follopwing links that your syntax is correct
http://www.dotnetperls.com/path-exists
http://msdn.microsoft.com/en-us/library/system.io.directory.exists.aspx
Let me know your findings