473,396 Members | 1,975 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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 7592
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

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

Similar topics

3
by: buran | last post by:
Dear ASP.NET Programmers, I encountered the following problem when running my project: Configuration Error Description: An error occurred during the processing of a configuration file...
10
by: Shawn | last post by:
JIT Debugging failed with the following error: Access is denied. JIT Debugging was initiated by the following account 'PLISKEN\ASPNET' I get this messag in a dialog window when I try to open an...
1
by: KMart | last post by:
Hello, I have a ASP.NET/C# application that uses the IE Web Controls. Everything was working fine. Then, for some unknown reason, everything stopped working. Here's the error information: ...
3
by: Randy | last post by:
Hello All, I'm getting a strange error when trying to perform a file upload. Here's the lines that uploads the file... sSaveLocation = Server.MapPath("PFPDocs") + "\\" + fileName;...
0
by: Costi Stan | last post by:
Hello, I get all the time JIT Debugging failed with the following error: Access is denied. message when trying to my a webservice. MSDN say to add DOMAIN/ASPNET user to Debugging Users. I get...
5
by: Seok Bee | last post by:
Dear Experts, I currently trying to use the FileUpload control from asp.net 2.0 to upload files. The uploading of the file I would like to store it in the Access Database. Unfortunately, I've no...
2
by: HelenWu | last post by:
I have two frames in index.html: <frameset cols="165,*"> <frame name="NCTnav" src="NCTnavHome.htm" scrolling="auto"> <frame name="NCTmain" src="http://www.yahoo.com"> </frameset> ...
0
Atli
by: Atli | last post by:
Hi. I'm trying to use php code I wrote last year when I was using Apache, so I'm pretty sure the code works. Its a simple code to upload an image and create a thumb of the image in another...
1
by: daraboy | last post by:
I have a Web home page which allows the IIS users account IUSR_Svr01 to view the page. Each link on the home page allows access to a sub folder, the access to the sub folder is restricted by the...
2
by: =?Utf-8?B?U2hhbQ==?= | last post by:
I am having the error when i execute my .net application i got this error. "Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED)) ". Can anyone help me to resolve this error....
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.