Jan 13, 2004

Jan 12, 2004

Response.BinaryWrite() Example

the code:
Dim fileStream As FileStream
Dim fileSize As Long

fileStream = New FileStream(fileName, FileMode.Open)
fileSize = fileStream.Length
onlyFileName = Path.GetFileName(fileName)
Response.Buffer = True

Dim Buffer(CInt(fileSize)) As Byte
fileStream.Read(Buffer, 0, CInt(fileSize))
fileStream.Close()
If (fileExt <> '') Then
Select Case (fileExt.ToLower())
Case '.htm'
fileType = 'text/HTML'
Exit Select
Case '.html'
fileType = 'text/HTML'
Exit Select
Case '.txt'
fileType = 'text/plain'
Exit Select
Case '.doc'
fileType = 'Application/msword'
Exit Select
Case '.rtf'
fileType = 'Application/msword'
Exit Select
Case '.pdf'
fileType = 'Application/pdf'
Exit Select
Case '.xls'
fileType = 'application/x-excel'
'Response.AddHeader('Content-Disposition',
'filename=''' & onlyFileName & '''')
Case '.pff'
fileType = 'application/ms-powerpoint'
Case '.ppt'
fileType = 'application/ms-powerpoint'
Case '.gif'
fileType = 'image/GIF'
Case '.jpg'
fileType = 'image/JPEG'
Case '.cdf'
fileType = 'application/x-cdf'
'Response.AddHeader('Content-Disposition',
'filename=''' & onlyFileName & '''')
"
Getting Started with BizTalk
Implementing Database Transactions with Microsoft .NET