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

Renaming file with Custom Progress

9 Answers 163 Views
Upload (Obsolete)
This is a migrated thread and some comments may be shown as answers.
Dave Miller
Top achievements
Rank 2
Dave Miller asked on 13 Apr 2008, 10:12 PM
How would I rename a file utilizing the Progress Monitoring found on the Demo at http://www.telerik.com/demos/aspnet/prometheus/Upload/Examples/CustomProgress/DefaultCS.aspx

9 Answers, 1 is accepted

Sort by
0
Dimcho
Telerik team
answered on 15 Apr 2008, 12:23 PM
Hello Dave Miller,

I'm not sure I understand your requirement. Do you want to change the text which appears in the RadProgressArea in front of the name of the uploading file (screenshot attached)? If this is so, you can change this text by using the following code:

RadProgressArea1.Localization["CurrentFileName"] = " your text here "

If you want to display a different name in the RadProgressArea for the currently uploaded file, you should use the CurrentOperationText key in the progress hashtable. You can see how to use it in the demo you have mentioned.

If this is not what you want, please give more detailed description about the functionality you want to achieve.



All the best,
Dimcho
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Dave Miller
Top achievements
Rank 2
answered on 15 Apr 2008, 12:37 PM
Dimcho,

I am not looking to change the text/filename showing in the progress area. What I want to do is rename the file being saved. I am not sure in this example where the uploading is actually being processed.

Thanks,
Dave
0
Accepted
Dimcho
Telerik team
answered on 16 Apr 2008, 04:01 PM
Hi Dave,

The Custom Progress example demonstrates the ability of RadProgressArea to monitor the progress of any measurable process. The selected file is uploaded on postback and if you want to rename and save it you should do this on the server side. These features are not demonstrates by the example because its purpose is to show only the upload progress.

You can easily manipulate the uploaded files using the provided solution in this link. It shows how to achieve the requested functionality using RadUpload control.

 
Best regards,
Dimcho
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Accepted
Dave Miller
Top achievements
Rank 2
answered on 16 Apr 2008, 08:21 PM
Dimcho,

Thanks, The link gave me what I needed.

I was on the right track but had the "TargetFolder" path set.

Dave
0
Chase Florell
Top achievements
Rank 1
answered on 22 Jul 2008, 04:38 PM
The posted link is broken.  I too would like to know how to rename a file after upload.
0
Veselin Vasilev
Telerik team
answered on 22 Jul 2008, 04:59 PM
Hi Chase Florell,

I hope that these links will be helpful:

http://www.telerik.com/help/aspnet-ajax/upload_raduploadmanipulatingfiles.html
http://www.telerik.com/help/aspnet-ajax/upload_raduploadtargetfolder.html


Best wishes,
Veskoni
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Dave Miller
Top achievements
Rank 2
answered on 22 Jul 2008, 05:09 PM
Chase,

Look at the example at http://www.telerik.com/DEMOS/ASPNET/Prometheus/Upload/Examples/ManipulatingTheUploadedFiles/DefaultCS.aspx

in the code behind:

foreach(UploadedFile validFile in RadUpload1.UploadedFiles)
                {
                    string targetFolder = Server.MapPath("~/Upload/Examples/ManipulatingTheUploadedFiles/MyFiles");
                    validFile.SaveAs(Path.Combine(targetFolder, validFile.GetName()), true);
                }

Simply change the "validFile.GetName()" to the new file name like :

validFile.SaveAs(Path.Combine(targetFolder, "newfile.jpg"), true);

or:

string strNewFileName = "newfile.jpg";
validFile.SaveAs(Path.Combine(targetFolder, strNewFileName), true);

also if you are dynamically changing the save path "targetFolder" make sure you don't set the "TargetFolder" attribute in the "<telerik:radupload />" on the .aspx

Hope that helps,

Dave
0
Chase Florell
Top achievements
Rank 1
answered on 20 Nov 2008, 01:51 AM
Ok i have it half way working.  Instead of renaming the file, it is creating a new file with the new name but leaving the old file... I am worried about this because they way my app works is EVERYONE will be uploading a file with the "Exact Same Name".  ValuePro.xml

 
    Protected Sub submitButton_Click()  
        Dim fName As String = Guid.NewGuid().ToString  
        For Each f As UploadedFile In RadUpload1.UploadedFiles  
            f.SaveAs(Server.MapPath("~\App_Data\ValuePro\") & fName & ".XML"True)  
        Next 
    End Sub 
 

So there is potential for two users to upload a file at the same time and the files get their wires crossed.  I do not want "ValuePro.Xml" to reside on the server anywhere...

thoughts?
0
Dave Miller
Top achievements
Rank 2
answered on 20 Nov 2008, 01:59 PM
Chase,

Using the code below should not be saving the file twice with both names. It should be saving just one file with the new fName string as the name. Was there a file named "ValuePro.Xml" to start?

Protected Sub submitButton_Click()     
        Dim fName As String = Guid.NewGuid().ToString     
        For Each f As UploadedFile In RadUpload1.UploadedFiles     
            f.SaveAs(Server.MapPath("~\App_Data\ValuePro\") & fName & ".XML", True)     
        Next    
    End Sub   
 

The only other thing is if you are uploading multiple files you would want to change it to something like this.

Protected Sub submitButton_Click()        
        Dim fName As String         
        For Each f As UploadedFile In RadUpload1.UploadedFiles    
            fName = Guid.NewGuid().ToString  
            f.SaveAs(Server.MapPath("~\App_Data\ValuePro\") & fName & ".XML", True)        
        Next       
    End Sub      
 

Regards,
Dave
Tags
Upload (Obsolete)
Asked by
Dave Miller
Top achievements
Rank 2
Answers by
Dimcho
Telerik team
Dave Miller
Top achievements
Rank 2
Chase Florell
Top achievements
Rank 1
Veselin Vasilev
Telerik team
Share this question
or