469,356 Members | 1,947 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,356 developers. It's quick & easy.

File UpLoad - C#.NET - Error: Access to the path xxx is denied

Hi,

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
  1. if( ( File1.PostedFile != null ) && ( File1.PostedFile.ContentLength > 0 ) )
  2.             {
  3.                 string fn = System.IO.Path.GetFileName(File1.PostedFile.FileName);
  4.                 string SaveLocation = Server.MapPath("Data") + "\\" +  fn;
  5.                 //string SaveLocation = "C:\\Inetpub\\wwwroot" + "\\" + fn;
  6.                 try
  7.                 {
  8.                     File1.PostedFile.SaveAs(SaveLocation);
  9.                     Response.Write("The file has been uploaded.");
  10.                 }
  11.                 catch ( Exception ex )
  12.                 {
  13.                     Response.Write
  14. "Error: " + ex.Message);
  15.                             }
  16.             }
  17.             else
  18.             {
  19.                 Response.Write("Please select a file to upload.");
  20.             }


Thanks,
Sasikumar.
Jun 21 '07 #1
7 7185
RedSon
5,000 Expert 4TB
If you are posting code please be sure to use CODE tags around your code.
Jun 21 '07 #2
If you are posting code please be sure to use CODE tags around your code.
sure... my apologies.. i'm very curious of my issue that i read the guidelines after posting the thread...
Jun 21 '07 #3
RedSon
5,000 Expert 4TB
It might be that your webserver has additional permissions on that folder. If its not the webserver then it is the operating system file permissions that are stopping you. Are you sure that both the webserver and the operating system permissions are set properly?
Jun 21 '07 #4
how we check webserver/OS permissions?
Jun 21 '07 #5
RedSon
5,000 Expert 4TB
how we check webserver/OS permissions?
For OS permissions you can right click on the folder and go to properties I think. As for webserver, you will have to read the documentation because I don't use IIS.
Jun 21 '07 #6
I've checked for the folder permission both at the OS level and at the webserver level. Both has write access. But still the issue exists.

Any suggestions????
Jun 21 '07 #7
RedSon
5,000 Expert 4TB
I've checked for the folder permission both at the OS level and at the webserver level. Both has write access. But still the issue exists.

Any suggestions????
Sorry Not much more I can think of. :(
Jun 21 '07 #8

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

5 posts views Thread by Seok Bee | last post: by
2 posts views Thread by =?Utf-8?B?U2hhbQ==?= | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.