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

Rename or save as when uploading file

1 Answer 120 Views
FileExplorer
This is a migrated thread and some comments may be shown as answers.
Atlas
Top achievements
Rank 1
Atlas asked on 04 Oct 2010, 09:48 PM

I would like to add a method to strip out special characters from a filename when it is uploaded, but I am not sure where to put the code. With the regular upload control you can use the saveas dialoge, but I am not sure where to implement this code in the file explorer control. My code looks like this:

if (e.Command == "UploadFile")
            {
                RadFileExplorer explorer = sender as RadFileExplorer;
                if (explorer != null)
                {
                    int ItemId = Convert.ToInt32(explorer.Attributes["ItemId"]);
                    string[] aFolder = e.Path.Split('/');
  
                    foreach (UploadedFile file in explorer.Upload.UploadedFiles)

1 Answer, 1 is accepted

Sort by
0
Dobromir
Telerik team
answered on 06 Oct 2010, 02:47 PM
Hi Nano,

Fiko already answered your support ticket on the subject. For convenience I will paste his answer here as well.

The best way and the best place to do this is inside the FileBrowserContentProvider's SaveFile method. In your case I recommend you to subclass the default provide which ships with radFileExplorer - Telerik.Web.UI.Widgets.FileSystemContentProvider and override its SaveFile method in order to achieve the desired result:
public override string StoreFile(UploadedFile file, string path, string name, params string[] arguments)
{
    return base.StoreFile(file, path, name, arguments);
}

Please note that you need to return the virtual path of the currently saved file. Then you can set the new provider to the RadFileExplorer control.

I hope this helps.


Greetings,
Dobromir
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
FileExplorer
Asked by
Atlas
Top achievements
Rank 1
Answers by
Dobromir
Telerik team
Share this question
or