Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

System.IO.CreateDirectory Exception

Status
Not open for further replies.

dragonwell

Programmer
Oct 21, 2002
863
US
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:
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;

    }

}
 
Have them check the .NET policies (it's a MMC snap-in).

Chip H.
 
You mean System.DirectoryServices needs to be listed in the Policy Assemblies in .NET Configuration?

That would need to be under "User", "Machine" or "Enterprise"?

I'm thinking that if they have done custom configuration they will probably not change it just for me, anyway.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top