473,394 Members | 1,759 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

how to unset/reset ReadOnly mode of an Excel file?

Ron
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
Nov 21 '05 #1
2 7497
"Ron" <an*******@discussions.microsoft.com> schrieb:
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?


You can try to specify 'FileShare.ReadWrite' in the constructor of your
'FileStream'. Maybe this helps.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #2
Ron
Thanks. I will give that a try.

-----Original Message-----
"Ron" <an*******@discussions.microsoft.com> schrieb:
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?
You can try to specify 'FileShare.ReadWrite' in the

constructor of your'FileStream'. Maybe this helps.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

.

Nov 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: lawrence | last post by:
Given a bunch of mixes variables, I'm in a situation where I can't know what type they are. Can I use unset to kill an object? unset($object); Can I use unset to kill a pointer to an open...
2
by: Ronny Sigo | last post by:
Hello all, As one of a few ways to let a user bring in data into my database I have made 3 excel files. Once the data are in the excel files my program checks if a required value (Taal (Dutch)...
1
by: PeteCresswell | last post by:
I'm working on a new report in an MS Access DB. The first anomaly was a message "This action will reset the current code in break mode." when the report was run. Seems TB something about my...
7
by: fasanay | last post by:
Hi everybody I have got the following PHP code which I am trying to convert to ASP any help will be appreciated...I have done most of it but I cant find a replace function for Unset in asp which...
1
by: Luis Esteban Valencia | last post by:
Here is my aspx code: ============= <%@ Page language="c#" Codebehind="WebForm3.aspx.cs" AutoEventWireup="false" Inherits="PDM.excel.WebForm3" %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0...
2
by: Suma | last post by:
Hi To open a notepad file, right now I am using Process.start. But this does not ensure that the file is opened in readonly mode How can I make a notepad file open in Readonly mode I do not...
5
by: comp.lang.php | last post by:
// NEW 11/27/2006: FINALLY, IF YOU ADDED OR DELETED OR DID ANY KIND OF FORM ACTION SUCCESSFULLY, DON'T RE-DISPLAY THE NEW EXPENSE ITEMS VIA $_POST if ($_POST && (!is_array($leaseObj->errorArray)...
1
by: Tim Zych | last post by:
Is it possible to replace a VB.Net DLL (class library output), referenced by an XL workbook, while the workbook is still open? Right now, if Excel is open and referencing the DLL, it can't be...
3
by: Mayur H Chauhan | last post by:
All, I am working on one product where we need to check for physical file is in use (if it is open by other application). What I found out is that I am able to trap for those files whose attribute...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.