I'm trying a simple code to upload a file to the server. When I click to Upload I get the following error message:
Error: Access to the path xxx is denied
The folder in which I'm trying to upload the file has all access. I've included
NETWORK SERVICE - with full control and
ASPNET - with full control to the folder.
But still getting the same error.
Any help on this would be greatly appreciated.
Here goes my code:
Expand|Select|Wrap|Line Numbers
- if( ( File1.PostedFile != null ) && ( File1.PostedFile.ContentLength > 0 ) )
- {
- string fn = System.IO.Path.GetFileName(File1.PostedFile.FileName);
- string SaveLocation = Server.MapPath("Data") + "\\" + fn;
- //string SaveLocation = "C:\\Inetpub\\wwwroot" + "\\" + fn;
- try
- {
- File1.PostedFile.SaveAs(SaveLocation);
- Response.Write("The file has been uploaded.");
- }
- catch ( Exception ex )
- {
- Response.Write
- "Error: " + ex.Message);
- }
- }
- else
- {
- Response.Write("Please select a file to upload.");
- }
Thanks,
Sasikumar.