Byte array to stream

J

Jon

We have a regular ASP website that uses the third party ASPUpload control
for uploading files. Those files are in the byte array format, ready to be
stored into SQL Server. I need to transfer that byte array to a .Net (2.0)
DLL (through COM) and then convert it to a filestream so that I can write it
to a directory on the server. I'm having trouble figuring out how to do
that.

Anyone have some ideas on the best way to do that?

Thanks
Jon
 
G

Guest

Here the basic idea. I'd recommend extra checks to see if path exists,
exception handling, etc.

Public Sub CreateFileFromBytes(ByVal fileAsBytes() As Byte, ByVal
pathToWrite As String)

Dim fs As FileStream = New FileStream(pathToWrite, FileMode.CreateNew)
fs.Write(fileAsBytes, 0, fileAsBytes.Length)
fs.Flush()
fs.Close()

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top