Click here to Skip to main content
15,891,431 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
hai..

i tried to upload a file. but it showing an error "unauthorized access exception Access to the path 'C:\afthab marg.jpg' is denied." please help me


C#
protected void Button1_Click(object sender, EventArgs e)



    {
        if (FileUpload1.PostedFile != null)
        {
            String filename = FileUpload1.PostedFile.FileName;// from here we can get the name of the file we have to upload
            FileUpload1.PostedFile.SaveAs("C:\\"+ filename);// here we have to get the location of the file 

        }
    }
Posted
Updated 11-Nov-11 22:18pm
v2

Looks like your appuser doesn't have the rights to the folder c:\\. In general, standard users don't have write access by default. Have you checked the permissions on the folder? If so, catch the exception for InnerDetails.
 
Share this answer
 
Vista and 7 do not provide write access to the root directory of any fixed disk except to administrators by default. The best solution is to store these files in a sub-directory, where full access can be established. It also helps to keep related data together.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900