Access denied to path , when uploading image to folder in server
        Posted  
        
            by apekshabs
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by apekshabs
        
        
        
        Published on 2009-03-10T06:32:57Z
        Indexed on 
            2010/04/23
            9:13 UTC
        
        
        Read the original article
        Hit count: 271
        
c#
Am getting error when you are going to upload the file on specified folder in the server. Here I am going to upload P6100083.jpg in storeimg folder. When I am going to upload I am getting the following error:
Access to the path 'C:\inetpub\vhosts\bookmygroups.com\httpdocs\storeimg\P6100083.jpg' is denied.
Can anyone help me... How to use permisiion and were to use...
My code is while uploading image
if (FileUpload1.HasFile) {
        float fileSize = FileUpload1.PostedFile.ContentLength;
        float floatConverttoKB = fileSize / 1024;
        float floatConverttoMB = floatConverttoKB / 1024;
        string DirName = "storeimg";
        string savepath = Server.MapPath(DirName + "/");
        DirectoryInfo dir = new DirectoryInfo(savepath);
        //   string savepath = "C:\\Documents and Settings\\ssis3\\My Documents\\Visual Studio 2005\\WebSites\\finalbookgroups\\" + DirName + "\\";
        if (fileSize < 4194304)
        {
            string filename = Server.HtmlEncode(FileUpload1.FileName);
            string extension = System.IO.Path.GetExtension(filename).ToUpper();
            if (extension.Equals(".jpg") || extension.Equals(".JPG") || extension.Equals(".JPEG") || extension.Equals(".GIF"))
            {
                savepath += filename;
                FileUpload1.SaveAs(savepath);
            }
        }
Thanks in advance
© Stack Overflow or respective owner