FileName of downloaded file

Last post 09-18-2009, 12:48 PM by gBurgur. 3 replies.
Sort Posts: Previous Next
  •  09-16-2009, 10:30 AM 55685

    FileName of downloaded file

    When the file gets downloaded to the temp directory, is there anyway to get that filename since it is not the "pure" filename.
     
    Filed under:
  •  09-16-2009, 11:51 AM 55690 in reply to 55685

    Re: FileName of downloaded file

    gBurgur,
     
    You can use args.FileName property to get the file name of the uploaded files.
     
    Here is an example:
     
    1. <%@ Page Language="C#" %>  
    2. <script runat="server">  
    3.     void Uploader_FileUploaded(object sender, UploaderEventArgs args)   
    4.     {   
    5.         Uploader uploader = (Uploader)sender;   
    6.         //Copys the uploaded file to a new location.   
    7.         //args.CopyTo("c:\\temp\\"+args.FileName);   
    8.     }   
    9. </script>  
    10.   
    11. <html>  
    12. <head>  
    13. </head>  
    14. <body>  
    15.     <form id="form1" runat="server">  
    16.        <CuteWebUI:Uploader runat="server" ID="Uploader1" OnFileUploaded="Uploader_FileUploaded"></CuteWebUI:Uploader>  
    17.     </form>  
    18. </body>  
    19. </html>  

    asp.net Chat http://cutesoft.net/ASP.NET+Chat/default.aspx
    Web Messenger: http://cutesoft.net/Web-Messenger/default.aspx
    asp.net wysiwyg editor: http://cutesoft.net/ASP.NET+WYSIWYG+Editor/default.aspx
    asp wysiwyg html editor: http://cutesoft.net/ASP
    asp.net Image Gallery: http://cutesoft.net/ASP.NET+Image+Gallery/default.aspx
    Live Support: http://cutesoft.net/live-support/default.aspx

  •  09-16-2009, 2:49 PM 55697 in reply to 55690

    Re: FileName of downloaded file

    I went throught the API and realize the "true" filename is args.FileName
    but that is not what I am asking.

    Example:
        A user uploads a file  "temp1.xml".
        but in the temporary download folder it is called:
            persisted.630f0c11-2cc1-4a77-ba91-0b177f23772b.temp1.xml.resx  
            
    Before I can copy the file to the destination folder,
    I have to make sure the destination folder doesn't contain
    a file called "temp1.xml".

    If another file already has a name of "temp1.xml" in the destination folder,
    I need to rename the newly downloaded file:
        temp1.xml
        to
        temp1_001.xml   <<< notice the "_001"

    Without the temporary filename of
        persisted.630f0c11-2cc1-4a77-ba91-0b177f23772b.temp1.xml.resx

        I need to copy the file using
        args.CopyTo("special_Folder__NOT_destination_folder")  
        and then rename the file to temp1_001.xml
        and then again copy it to the true destination folder.

    Instead of doing a double-copy just to rename the file to "*_001.xml",
        I would like to rename the file myself from:
        persisted.630f0c11-2cc1-4a77-ba91-0b177f23772b.temp1.xml.resx
        to
        temp1_001.xml
        and then copy it to the destination folder.
        
    It means a single file copy instead of the double file copy.

    Thus, I need someway to get the filename called:
        persisted.630f0c11-2cc1-4a77-ba91-0b177f23772b.temp1.xml.resx
        but I do not see anything in the API about that.

    Is there anyway to get that filename? (persisted.630f0c11-2cc1-4a77-ba91-0b177f23772b.temp1.xml.resx)
        
    Thanks,
    Gene
    Filed under:
  •  09-18-2009, 12:48 PM 55741 in reply to 55685

    Re: FileName of downloaded file

    Kenneth at CuteSoft emailed me the answer directly so I am posting it here.
     
     Response.Write("persisted." + args.FileGuid + ".resx");
    and in vb.Net  
    Dim sHoldthis As String = "persisted." + args.FileGuid.ToString + ".resx"   
     
    If you look at the property directly in the Property Viewer,
    args.FileGuid =Nothing
     
    so for whatever reason, it has to be directly in the code to 
    retrieve the value.

     
    Thanks Kenneth
     
View as RSS news feed in XML