This is a migrated thread and some comments may be shown as answers.

Overwrite on file drag

2 Answers 50 Views
FileExplorer
This is a migrated thread and some comments may be shown as answers.
Koren
Top achievements
Rank 1
Koren asked on 17 Mar 2011, 08:49 PM
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 Answers, 1 is accepted

Sort by
0
Dobromir
Telerik team
answered on 21 Mar 2011, 10:07 AM
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
0
Koren
Top achievements
Rank 1
answered on 24 Mar 2011, 05:03 PM
Thank you!  The only change I had to make was to add a MoveFile override also.
Tags
FileExplorer
Asked by
Koren
Top achievements
Rank 1
Answers by
Dobromir
Telerik team
Koren
Top achievements
Rank 1
Share this question
or