We have a webpage that allows users to upload a file to shared folder. There is a gridview which contains the list of uploded file names. Once the file is uploaded, the filename is added with a hyperlink in gridview. On click of hyperlink, FileDownload window should appear which allows users either to open the file or save the file. File should be opened only in ReadOnly format.So, we are using below code in btnUpload_Click method FileUpLoad1.SaveAs(attachmentSharePath + "\\" + attachmentnID + "." + extension); //Applying read-only attribute to the uploaded file so that it is Read-Only formatFile.SetAttributes(attachmentSharePath + "\\" + attachmentID + "." + extension, FileAttributes.ReadOnly); A check box is present beside every attachment which allows users to delete attachment from the grid view and the shared folder. Updating the attributes of the file to Normal is necessary in order to delete it (since the attributes earlier was ReadOnly)//btnDelete_Click method - Setting File attribute of the attachment to normal so that it can be deleted File.SetAttributes(attachmentSharePath + "\\" + AttachmentNameInSharedFolder, FileAttributes.Normal);//Delete the attachment from the attachment share File.Delete(attachmentSharePath + "\\" + attachmentnID + "." + extension);This is working fine when we run it locally (within VS2008). File is getting uploaded. When I deploy the website to the webserver (Win 2008 R2) and try to upload the file through the webpage, it doesn't work!. Below is the error logged in eventvwr:at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy) at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy) at System.IO.FileStream..ctor(String path, FileMode mode) at System.Web.HttpPostedFile.SaveAs(String filename) at System.Web.UI.WebControls.FileUpload.SaveAs(String filename) at btnUpload_Click(Object sender, EventArgs e)</StackTrace><Parameters>UploadClick method Error while Uploading</Parameters><SourceCode>System.UnauthorizedAccessException</SourceCode><ErrorMessage>Access to the path '\\aitdsql34\PC\1.docx' is denied.</ErrorMessage>We have given full permissions to ASPNET account on the shared folder. Please let me know if anything else need to be done.
sravanig17
Member
16 Points
10 Posts
Access denied while File Upload (permissions given to ASPNET account)
Mar 24, 2011 04:19 AM|LINK