Forum Moderators: open
I need my ASP.NET application to create and delete directories. I have asked my hosting provider to setup a public folder that is has its permissions set to read/write. I know that this public folder has these permissions because my application can create and delete files inside this directory. My problem is that when I try to create a directory inside this public folder, I get the following error...
System.IO.FileNotFoundException: Could not find file "D:\folder\example.com\html\public\test".
This is the code that I've been using (and it has been working perfectly on my development machine)...
Dim strDir As String = "D:\folder\example.com\html\public\test"
Dim dir As New System.IO.DirectoryInfo(strDir)
If dir.Exists = False Then
'create the directory
dir.Attributes = IO.FileAttributes.Directory
dir.Create()
End If
I've been told by my hosting provider that everything is set properly on their end, but I don't know what else could be giving me the error. When I create the directory through ftp then dir.Exists = True so I know that I have the correct path the my public folder.
Please, if anyone has any suggestions I'd be grateful if you could share them with me. I don't know whether or not my hosting provider is actually to blame or if I need to modify my code. I've been trying to resolve this for 2 days and between my and my provider, we've still yet to come up with a solution.
[edited by: engine at 2:06 pm (utc) on Oct. 16, 2003]
[edit reason] widgetised [/edit]
private void CreateDirectory(string path)
{
try
{
DirectoryInfo di = new DirectoryInfo(path);
if(di == null)
{
di.Create();
}
}
catch(Exception ex)
{
Response.Write(ex);
}
}
On a local machine, it should execute just fine if the ASP.NET process has read/write permissions both in the NTFS file system and also in IIS. If both are not in sync, then the opertaion will fail.
Also, try using try..catch blocks to see if it is a permissions issue or if the directory exists already. Chances are, the host did not setup the virtual directory in IIS to be read/write and/or did not set the proper permissions on the local folder.
HTH,
Bill P.