How to get file name of uploaded and renamed file in FileUploaded() event

2 posts, 1 answers
  1. Tihomir
    Tihomir avatar
    2 posts
    Member since:
    Oct 2010

    Posted 10 Jun 2011 Link to this post

    Hi all,
    Please can you tell me how can i get a filename of already uploaded and renamed file.
    I use FileUploadStarting() event to upload and rename  file (Test.txt -> 123Test.txt).
    I want to catch the new file name in FileUploaded() event but I didn't success.

    Thanks
    P.S. the file is uploaded successfully with the new file name.
  2. Answer
    Alex Fidanov
    Admin
    Alex Fidanov avatar
    636 posts

    Posted 15 Jun 2011 Link to this post

    Hi Tihomir,

    You can send the new file name as parameter back to the client from the server. In the RadUploadHandler yuo can ovveride the GetAssociatedData method and return the file name. In the FileUploaded event, you can request the parameter through the HandlerData property:

    // code in the handler
    public override Dictionary<string, object> GetAssociatedData()
    {
        Dictionary<string, object> associatedData = base.GetAssociatedData();
        if (this.IsFinalFileRequest())
        {
            associatedData.Add("NewFileName", this.GetFileName());
        }
        return associatedData;
    }

    private void upload_FileUploaded(object sender, FileUploadedEventArgs e)
    {
        var newName = e.HandlerData.CustomData["NewFileName"];
    }


    Best wishes,
    Alex Fidanov
    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
  3. DevCraft banner
Back to Top