none
retring the Blob format data and showing them in different format. RRS feed

  • Question

  •  

    Dear Team,

     

     I have a requirement that

     

    i am displaying the records in the datagrid which will are fetched from the database ,  which has 3 columns 

    1. id

    2. the blob data 

    3. the file name  ( this can be of any format ) like .txt,.pdf etc.

    so when i click on the perticular file name ( which is just an name ) the file should get opened in its corresponding format by reading the data from its perticular blob column.

     

    expecting an responce from your side

     

     

    Thanx and regards

     

    Shaik Abdul Gani

    Thursday, December 4, 2008 12:20 PM

Answers

  • Hi

     

    I guess the easier way to achieve what you need is by saving the blob data into the temporary file and invoking the relevant application on it.

     

    Files can be created using System.Io.File. You can either create them in current user's %TEMP% folder or the dedicated folder assigned to your application. To make sure you do not get conflicts if you allow duplicate names, you can inject Guid.NewGuid().ToString() or another random blob between the file name and its extension.

     

    If you want to open the 'default application' associated with this file, you can use Process.Start and provide custom ProcessStartInfo instance with UseShellExecute = true. You will need to make sure that the extension of the temp file created is the same as the original file name.

     

    Friendly advice: from security point of view you have to fully trust the database you take the blob from, otherwise malicios users can put anything there and make it run on your client computers. Make sure this design is reviewd by security experts...

     

    Regards,

     Nissim

    Friday, December 5, 2008 11:55 PM
    Moderator