Software Development : A dizzy job...keeping abreast and being competitive is a 24X7 involvement
Jan 31, 2004
Jan 28, 2004
Jan 27, 2004
Jan 23, 2004
Jan 21, 2004
Jan 20, 2004
Jan 17, 2004
Jan 15, 2004
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 & '''')
"
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 & '''')
"
Jan 7, 2004
Subscribe to:
Posts (Atom)