Uploading a file that already exists

Last post 09-07-2008, 11:45 PM by Kenneth. 1 replies.
Sort Posts: Previous Next
  •  09-06-2008, 8:51 PM 43675

    Uploading a file that already exists

    Is there a way to control whether to allow an uploaded file to overwrite an existing file of the same name?
     
    Diane
  •  09-07-2008, 11:45 PM 43678 in reply to 43675

    Re: Uploading a file that already exists

    Hi Diane,

    You can try the following method
     void Uploader_FileUploaded(object sender, UploaderEventArgs args)
        {
            Uploader uploader = (Uploader)sender;
            //test folder is the path to save the file
            string path = Server.MapPath("~/test" + args.FileName);
            //if the file exist
            if (System.IO.File.Exists(path))
            {
                //you want to do
                return;
            }
                
            
        } 
     
    Regards
    Ken

     

View as RSS news feed in XML