Overwrite on file drag

3 posts, 0 answers
  1. Koren
    Koren avatar
    68 posts
    Member since:
    Oct 2010

    Posted 17 Mar 2011 Link to this post

    Is there any way to allow an overwrite when someone drags a file to a folder that already has a file with that name?  I know it works on the Upload functionality but I need it to allow it for a drag and drop also.

    thanks!
  2. Dobromir
    Admin
    Dobromir avatar
    1633 posts

    Posted 21 Mar 2011 Link to this post

    Hi Koren,

    You can achieve the required functionality by implementing a custom filebrowser content provider to RadFileExplorer and override the CopyFile() method to delete the file in the destination folder (if already exists) and then perform the copy, e.g.:
    public override string CopyFile(string path, string newPath)
    {
        string oldPhysicalPath = MapPath(path);
        string newPhysicalPath = MapPath(newPath);
        if(File.Exists(newPhysicalPath)
        {
            try
            {
                File.Delete(newPhysicalPath);
            }
            catch(UnauthorizedAccessException)
            {
                return "NoPermissionsToDeleteFile";
            }
        }
     
        return base.CopyFile(path, newPath);
    }


    All the best,
    Dobromir
    the Telerik team
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Koren
    Koren avatar
    68 posts
    Member since:
    Oct 2010

    Posted 24 Mar 2011 Link to this post

    Thank you!  The only change I had to make was to add a MoveFile override also.
Back to Top