How to Open Binary Data with default App

mikemikk

Member
Joined
Jul 3, 2007
Messages
10
Programming Experience
10+
(This is a repost of what I asked on a1vbcode)

Hello, Would someone be so kind as to tell me how one would go about opening binary data, from vb.net, using the system default application. I've included the code I am using now; but would like to avoid the temporary file.

VB.NET:
' put binary data (tif or pdf in my case) into file on filesystem
' depending on file type
dim fileType as integer = oracledatareader.getint32(1)
dim fileName as string = nothing

if fileType = 1 Then ' PDF
   fileName = "C:\temp.pdf"
else if fileType = 2 Then ' TIF
   fileName = "C:\temp.tif"
end if

dim binData as oracleblob = oracledatareader.getoracleblob(0)
Dim fileStrm As New IO.FileStream(fileName, IO.FileMode.Create, IO.FileAccess.Write)

' the Value method of OracleBlob returns a byte array
fileStrm.Write(binData .Value, 0, binData .Value.Length - 1)
fileStrm.Close()
fileStrm.Dispose()

' open new file using system default application
dim myProcess = System.Diagnostics.Process.Start(fileName, Nothing)
myProcess.WaitForExit()
myProcess.Close()
myProcess.Dispose()

' clean up
my.Computer.Filesystem.DeleteFile(fileName)

Is there a way to do this without writing to the filesystem first? :confused:
 
Is there a way to do this without writing to the filesystem first?
No, there isn't, that's where those applications need to read the data from.
 
Back
Top