Renaming file with Custom Progress

Thread is closed for posting
10 posts, 2 answers
  1. Dave Miller
    Dave Miller avatar
    64 posts
    Member since:
    Oct 2004

    Posted 13 Apr 2008 Link to this post

    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
  2. Dimcho
    Admin
    Dimcho avatar
    45 posts

    Posted 15 Apr 2008 Link to this post

    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
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Dave Miller
    Dave Miller avatar
    64 posts
    Member since:
    Oct 2004

    Posted 15 Apr 2008 Link to this post

    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
  5. Answer
    Dimcho
    Admin
    Dimcho avatar
    45 posts

    Posted 16 Apr 2008 Link to this post

    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
  6. Answer
    Dave Miller
    Dave Miller avatar
    64 posts
    Member since:
    Oct 2004

    Posted 16 Apr 2008 Link to this post

    Dimcho,

    Thanks, The link gave me what I needed.

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

    Dave
  7. Chase Florell
    Chase Florell avatar
    257 posts
    Member since:
    Apr 2005

    Posted 22 Jul 2008 Link to this post

    The posted link is broken.  I too would like to know how to rename a file after upload.
  8. Veselin Vasilev
    Admin
    Veselin Vasilev avatar
    2992 posts

    Posted 22 Jul 2008 Link to this post

    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
  9. Dave Miller
    Dave Miller avatar
    64 posts
    Member since:
    Oct 2004

    Posted 22 Jul 2008 Link to this post

    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
  10. Chase Florell
    Chase Florell avatar
    257 posts
    Member since:
    Apr 2005

    Posted 19 Nov 2008 Link to this post

    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?
  11. Dave Miller
    Dave Miller avatar
    64 posts
    Member since:
    Oct 2004

    Posted 20 Nov 2008 Link to this post

    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
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017