MoveTo() and file overwritting

Last post 03-31-2010, 4:39 AM by michael1111111111. 2 replies.
Sort Posts: Previous Next
  •  01-07-2009, 10:48 AM 47512

    MoveTo() and file overwritting

    when in the sub Uploader_FileUploaded() event handler, can the args.MoveTo(destinationPath) call be set to overwrite if the file already exist? or to skip moving the file, if desired, in such a case?
     
    basically, are there any options for controlling how to handle a duplicate file situation?
     
    thanks,
    al
  •  01-07-2009, 1:38 PM 47524 in reply to 47512

    Re: MoveTo() and file overwritting

    Hi,
     
    You can delete the file if it exists:
     
    if(System.IO.File.Exists(filepath))
        System.IO.File.Delete(filepath);
    args.MoveTo(filepath);
     
    or you can report error if you do not want to override it:
     
    if(System.IO.File.Exists(filepath))
    {
        SendAlert("File already exists");
        return;
    }
    args.MoveTo(filepath);
     
    Regards,
    Terry
  •  03-31-2010, 4:39 AM 59762 in reply to 47512

    Re: MoveTo() and file overwritting

    Greetings,
     
    i'm also experiencing the same issue, some feedback would be nice. I'll continue to keep working at it, if i find a solution i will post it.
     
    Regards,
    Michael
View as RSS news feed in XML