Go Premium for a chance to win a PS4. Enter to Win

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,491 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 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

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

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

A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…

916 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