Posted on: 7/22/2015 2:47:03 AM | Views : 834

I know this question has been asked previously and been answered by a number of people but frankly none of them work for me and none of them make sense to me in my problem. I have a very simple asp.net page that is allowing the user to upload a file (say an image) through a FileUpload control. My code then simply saves the file on the disk. Here's the twist. If I simply save the file to Sever.MapPath("~/") location, the page saves the uploaded file with no issue. However, I would like to organize the uploaded files and put them in subfolders. So I have added a utility class called FileHandler which gets a fileNumber and creates some subdirectories under Server.MapPath("~/") location. I check and all the folders and subfolders have been created with no issue. Now when I try to save the uploaded file to the newly created subfolder, I get the access is denied exception. Here's the relevant part of my code:
if (FileUpload.PostedFile.ContentT ...

Go to the complete details ...