dragonwell
Programmer
I am attempting to call the CreateDirectory method. It works fine on my development machine, but not on the server where the app is being hosted. My host claims to have granted write permissions on the directory in which I am trying to create a new directory, (although I have not verified this, I do believe them)
What's up?
The Error:
System.IO.DirectoryNotFoundException: Could not find a part of the path "D:\". at System.IO.__Error.WinIOError(Int32 errorCode, String str) at System.IO.Directory.InternalCreateDirectory(String fullPath, String path) at System.IO.Directory.CreateDirectory(String path)
The Code:
What's up?
The Error:
System.IO.DirectoryNotFoundException: Could not find a part of the path "D:\". at System.IO.__Error.WinIOError(Int32 errorCode, String str) at System.IO.Directory.InternalCreateDirectory(String fullPath, String path) at System.IO.Directory.CreateDirectory(String path)
The Code:
Code:
public class MyFile {
private string directory;
private string physicalPath;
private static readonly string basePath;
static MyFile(){
basePath = HttpContext.Current.Server.MapPath(ConfigurationSettings.AppSettings["FileDirectory"]);
// "FileDirectory" is set to "Uploads" in the web.config
//(an actual folder in my web root with write permissions on it)
}
// Method MakeDirectory() should set and return this.physicalPath,
// a fully qualified UNC path to the new folder
// that was created
protected string MakeDirectory(){
Guid dir = Guid.NewGuid();
StringBuilder path = new StringBuilder();
path.Append(basePath);
path.Append(@"\");
path.Append(dir.ToString());
this.physicalPath = path.ToString();
if(!(System.IO.Directory.Exists(this.physicalPath)))
System.IO.Directory.CreateDirectory(this.physicalPath);
if(System.IO.Directory.Exists(this.physicalPath))
this.directory = dir.ToString();
return this.physicalPath;
}
}