Solved

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

Posted on 2006-07-24
3
1,479 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 200 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 50 total points
ID: 17169641
make sure the file is not readonly
0

Featured Post

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

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

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Suggested Courses

623 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