Hello,
the following sub (below) reads an excel file to a webpage
using BinaryReader. If anyone tries to modify the excel
file from the browser this places the excel file in
ReadOnly mode, and no one can then touch the file, I can't
delete it, etc. The file will still display on the
browser. The only way I have been able to release the
file from ReadOnly mode is to reboot the server computer.
Obviously, I can't keep doing that. Does anyone know if
there is a way to reset/unset the ReadOnly mode of the
Excel file? or how to make it not go into ReadOnly mode?
------------------------------------------------------
Private Sub GetFile()
Dim FilePath As String = Cache("strFile").ToString
If Not Dir(FilePath).Equals("") Then
Dim fs As New FileStream(FilePath, FileMode.Open,
FileAccess.Read)
Dim bw As New System.IO.BinaryReader(fs)
Dim byt() As Byte, i As Integer
byt = bw.ReadBytes(CInt(fs.Length))
i = byt.Length()
Response.ContentType = "application/vnd.ms-excel"
Response.OutputStream.Write(byt, 0, i)
Response.OutputStream.Close()
response.write("testing")
End If
End Sub
----------------------------------------------------------
Thanks,
Ron