Solved

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

Posted on 2006-07-24
3
1,457 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
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 17

Accepted Solution

by:
lem2802 earned 50 total points
ID: 17169641
make sure the file is not readonly
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
ASP.net VB.net Email  a webpage 3 30
Visual Studio: built-in keystroke automation 2 46
How to access a DataBinder.Eval variable using C# ? 4 27
Syntax Error 2 42
Lots of people ask this question on how to extend the “MembershipProvider” to make use of custom authentication like using existing database or make use of some other way of authentication. Many blogs show you how to extend the membership provider c…
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 …
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
A short film showing how OnPage and Connectwise integration works.

932 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

10 Experts available now in Live!

Get 1:1 Help Now