Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Error: Access to the path "D:\Inetpub\wwwroot\WebSite1\troubleDocs\4040CA.pdf" is denied.

Posted on 2006-07-24
3
Medium Priority
?
1,484 Views
Last Modified: 2008-02-01
Hi

I am trying to upload a file in the folder using the following code:

 void Button1_Click(object sender, EventArgs e)
    {
               string fn = System.IO.Path.GetFileName(File1.PostedFile.FileName);
            string SaveLocation = Server.MapPath("troubleDocs")+ "\\" + fn;
            
            string fn2 = System.IO.Path.GetFileName(File2.PostedFile.FileName);
            string SaveLocation2 = Server.MapPath("partsDocs")+ "\\" + fn2;
            try
            {
                  File1.PostedFile.SaveAs(SaveLocation);
                  File2.PostedFile.SaveAs(SaveLocation2);
                  Response.Write("The file has been uploaded.");
            }
            catch ( Exception ex )
            {
                  Response.Write("Error: " + ex.Message + ex.StackTrace);
                              }

I gave permissions to my user account in the network and the ASP.NET Web admin account.

When I try to upload it gives me the following error.


Error: Access to the path "D:\Inetpub\wwwroot\wwwdev\admintool\WebSite1\troubleDocs\4040CA.pdf" is denied. at System.IO.__Error.WinIOError(Int32 errorCode, String str) at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, Boolean useAsync, String msgPath, Boolean bFromProxy) at System.IO.FileStream..ctor(String path, FileMode mode) at System.Web.HttpPostedFile.SaveAs(String filename) at ASP.Default_aspx.Button1_Click(Object sender, EventArgs e) in D:\Inetpub\wwwroot\wwwdev\admintool\WebSite1\Default.aspx:line 111



Any advice will be greatly appreciated. How do I upload my file to the folder troubleDocs?

Thanks
.
0
Comment
Question by:Watson_User
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 7

Assisted Solution

by:ayha1999
ayha1999 earned 600 total points
ID: 17169456
Hi,
Right click 'troubleDocs' > securty > permission and give IUSR_yourmacine and aspnet accounts write permission on the folder and try again.

ayha
0
 
LVL 7

Expert Comment

by:brdrok
ID: 17169489
IIS and System Admin is not my forte but you if you are running IIS 6.0, you might want to investigate into this whole "Applicatoin Pool" thingie.  

here are a couple links to get you started:
http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/2a231dcb-d786-4b6d-b3ba-bda04061a5e7.mspx?mfr=true

http://www.developer.com/net/asp/article.php/2245511

hope this helps.
0
 
LVL 18

Accepted Solution

by:
Elvio Lujan earned 150 total points
ID: 17169641
make sure the file is not readonly
0

Featured Post

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have developed many web applications with asp & asp.net and to add and use a dropdownlist was always a very simple task, but with the new asp.net, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Suggested Courses

671 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question