Solved

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

Posted on 2006-07-24
3
1,452 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
3 Comments
 
LVL 7

Assisted Solution

by:ayha1999
ayha1999 earned 200 total points
Comment Utility
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
Comment Utility
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 17

Accepted Solution

by:
lem2802 earned 50 total points
Comment Utility
make sure the file is not readonly
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

762 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now