473,847 Members | 1,508 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

5 New Member
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 7627
RedSon
5,000 Recognized Expert Expert
If you are posting code please be sure to use CODE tags around your code.
Jun 21 '07 #2
sforsasi
5 New Member
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 Recognized Expert Expert
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
sforsasi
5 New Member
how we check webserver/OS permissions?
Jun 21 '07 #5
RedSon
5,000 Recognized Expert Expert
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
sforsasi
5 New Member
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 Recognized Expert Expert
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
2153
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 required to service this request. Please review the specific error details below and modify your configuration file appropriately. Parser Error Message: Access is denied: 'ExportTechnologies.WebControls.RTE'
10
8723
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 asp.net page. If I press OK then I get a page with this message: Server Application Unavailable The web application you are attempting to access on this web server is currently unavailable. Please hit the "Refresh" button in your web browser...
1
4496
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: Server Error in '/application' Application. ---------------------------------------------------------------------------- ----
3
4224
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; fileInput.PostedFile.SaveAs(sSaveLocation); When it runs, I'm getting a "Access to the path xxx is denied" error. On the server (Server 2003) I've given the ASP.NET and Everyone Full Control but still I get the error. I've also given IUSR_machinename Full...
0
3207
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 the same error all the time even with this. I haven't changed my project settings. Can anyone tell me what to try next?
5
6578
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 idea how I can do that. Can anyone provide me some solution by writing the code in vb.net? Many thanks in advance. Regards,
2
7738
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> from frame "NCTnav", I have a link, when I click this link, I need to load http://www.google.com (for example) into frame "NCTmain". The code in NCTnavHome.htm like: <script language="JavaScript" type="text/JavaScript"> function...
0
2732
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 file. This worked fine on Apache but when I try to use it on IIS 5 I get this error PHP Warning: File upload error - unable to create a temporary file in Unknown on line 0
1
5198
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 user providing the Domain, Account Name and Password. My problem is that some users are presented with the access dialog box and provided the details are correct, they gain access, but other users are not presented with the dialog box and instead...
2
1782
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. Thnks in advnz..
0
9732
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10987
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10652
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10343
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9486
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7885
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5914
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4535
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4125
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.