Hi all,
I am very happpy to return back again to you.
This time i have a critical problem about uploading files on the server by asp.net.
I choosed the HTML control "File" and Make it run as server control , and got its file name by the statement
string fname=File1.PostedFile.FileName
then i want to save it on the server Hard Disk so i used the statement :

try
{
File1.PostedFile.SaveAs(Server.MapPath("Project\\"+ff));
}
catch
{
Directory.CreateDirectory(Server.MapPath("Project\\"+ff));
File1.PostedFile.SaveAs(Server.MapPath("Project\\"+ff));
}

When running the page the following exception occured
Access to the path "c:\inetpub\wwwroot\Cubicle\Project\MyFile.doc" is denied.
which "c:\inetpub\wwwroot\Cubicle\" is my project directory (my project name is Cubicle)
Note : i configured the IIS options to be write ,read, and Directory browsing . and the problem is still exist .
Can any one help me ?
Thank You.

Recommended Answers

All 5 Replies

try

{
					File1.PostedFile.SaveAs(Server.MapPath("\\Project")+"\\" + ff);
				}
				catch
				{
					try
					{
						Directory.CreateDirectory(Server.MapPath("Project"));
						File1.PostedFile.SaveAs(Server.MapPath("Project")+"\\" + ff);
					}
					catch(Exception exp)
					{
						string message = exp.Message;
					}
				}

are u sure u entered in the form tag enctype="multipart/form-data"?

Thank you All
i have solved the problem from IIS Configuration by right click on the project name (from IIS window) and then All Tasks -> Permission Wizard and select read,write permissions.
it is solved now . and was no problem with the code .
Thank you again .

hello all, I'm new here
I try to follow everything in Google search to resolve my problem
but nothing done
I'm trying to upload file in asp.net
the same error of " Access to the path 'c:\inetpub\wwwroot\aa' is denied. " repeated every time I try to upload
so how to manage this problem ? I put all privileges to aspnet user and also to all user , but nothing changed
any help pleas , please

hello all, I'm new here
I try to follow everything in Google search to resolve my problem
but nothing done
I'm trying to upload file in asp.net
the same error of " Access to the path 'c:\inetpub\wwwroot\aa' is denied. " repeated every time I try to upload
so how to manage this problem ? I put all privileges to aspnet user and also to all user , but nothing changed
any help pleas , please

There are two places the permissions need to fixed at for upload to work:
1. IIS on the folder you want to upload you need to check the allow write check box
2. right click the actual folder in file explorer and allow everyone to write to this folder. Please remember the web user is a low permission user IIS_ somthing.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.