473,657 Members | 2,996 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 7606
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
2140
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
8699
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
4484
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
4213
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
3198
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
6570
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
7725
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
2721
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
5179
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
1772
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
8384
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8302
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
8820
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
8718
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
7314
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...
0
5630
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4300
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1937
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1601
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.