Results 1 to 3 of 3

Thread: Opening files stored in DB

  1. #1

    Thread Starter
    Member Walter_Ego's Avatar
    Join Date
    Jun 2004
    Posts
    50

    Opening files stored in DB

    Hello,

    I am storing files of different types on a varbinary field in a SQL Server 2005 db.

    How can I open the files with its default programme,
    i.e. open pdf files in acrobat, jpegs in picture viewer, etc. ?

    cheers

  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Opening files stored in DB

    Make sure you store the extension of the file (and name would be good as well) in the database as well. Then, retrieve the file and write it to disk using the name and extension you have. Then, System.Diagnostics.Process.Start() it.

  3. #3
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Opening files stored in DB

    I should be clearer... you'll get a byte array from the database. Use a BinaryWriter to write to a FileStream object, you can use the FS to save a file to disk.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width