Reputation: 5150
I am trying to create a directory if it does not exist. It correctly goes into the code to create the directory because it doesn't exist. But then it gives me the following error:
DirectoryNotFoundException was unhandled
Could not find part of the path "\192.168.22.2\2009"
var fileYear = createdDate.Value.Year.ToString();
var fileMonth = createdDate.Value.Month.ToString();
var rootDir = @"\\192.168.22.2";
if (!File.Exists(Path.Combine(rootDir,fileYear)))
{
// Create the Year folder
Directory.CreateDirectory(Path.Combine(rootDir,fileYear));
}
Upvotes: 0
Views: 1964
Reputation: 216290
You need to have a share name after the @"\\192.168.22.2"
.
Something like @"\\192.168.22.2\MySharedFolder"
.
You cannot create a subfolder from that root dir
Upvotes: 1