Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# ASP.NET
hi,
I want to save file in folder in the server using filebrowser for this i have written code as
try
        {
            DirectoryInfo dir = new DirectoryInfo(Server.MapPath("UploadImages"));
           foreach(FileInfo files in dir.GetFiles())
           {
 
            files.Delete();
 
           }
 
            if (FileUpload2.HasFile)
            {
                string strImagePath = FileUpload2.PostedFile.FileName.ToString();
                imagename = strImagePath;
                FileUpload2.PostedFile.SaveAs(Server.MapPath("UploadImages\\" + strImagePath));
                if (FileUpload2.PostedFile.ContentLength > 2451281)
                {
                    //spanError.InnerText = "Invalid Size";
                    //  UpLoadValidator.Visible = false;
                    //  RequiredFieldValidator3.ErrorMessage = "";
                    //  return;
                }
                else
                {
                    spanError.InnerText = "";
                    //UpLoadValidator.Visible = false;

                    Session["fileByte"] = FileUpload2.FileBytes;
 
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "starScript", "closePopUp();", true);
 
                    //  ScriptManager.RegisterStartupScript(this, this.GetType(), "starScript", "closePopUp(" + .Value + ");", true);

                }
                
 
               // ScriptManager.RegisterStartupScript(this, this.GetType(), "starScript", "alertshow();", true);
            }   
        }
        catch (Exception ex)
        {
            throw ex;
        }
This code is working for me,but the problem is when i copy my same code in other computer (pc) the code does'nt work .the code works only in my pc not other .
It is giving me error as
“The given path's format is not supported”
Posted 27-Dec-12 19:23pm
Edited 27-Dec-12 20:04pm
ridoy51.8K
v2

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Share the folder where you want to save the file and give network Service and ASP.NET
it will work, if dose't the check IIS identity, and give permission to that user.
  Permalink  

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



Advertise | Privacy | Mobile
Web04 | 2.8.140926.1 | Last Updated 28 Dec 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100