By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,168 Members | 2,598 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,168 IT Pros & Developers. It's quick & easy.

Logging to open file

P: n/a
I have a small VB.NET application that captures left clicks, right clicks
and key presses and automatically logs them to a csv file every 1 minute.
The issue is that if I want to look at the log file, I get an error because
the app is trying to write to the log file and it is open.

How can I circumvent this issue?

Thanks,
Drew
Nov 21 '05 #1
Share this Question
Share on Google+
7 Replies


P: n/a
Can you paste the sample...

Regards,
C#, VB.NET , SQL SERVER , UML , DESIGN Patterns Interview question book
http://www.geocities.com/dotnetinterviews/

Nov 21 '05 #2

P: n/a
When you look at the log file, are you opening it for read or for write?

--

Best regards,

Carlos J. Quintero

MZ-Tools: Productivity add-ins for Visual Studio .NET, VB6, VB5 and VBA
You can code, design and document much faster.
Free resources for add-in developers:
http://www.mztools.com

"Drew" <dr********@NOswvtc.dmhmrsas.virginia.SPMgov> escribió en el mensaje
news:Oy**************@TK2MSFTNGP10.phx.gbl...
I have a small VB.NET application that captures left clicks, right clicks
and key presses and automatically logs them to a csv file every 1 minute.
The issue is that if I want to look at the log file, I get an error because
the app is trying to write to the log file and it is open.

How can I circumvent this issue?

Thanks,
Drew

Nov 21 '05 #3

P: n/a
I am opening it in Notepad, so I guess that I am opening it for writing...
How should I review this log while the program is running?

Do you want me to post all the code?

Thanks,
Drew

"Carlos J. Quintero [VB MVP]" <ca*****@NOSPAMsogecable.com> wrote in message
news:eQ**************@TK2MSFTNGP10.phx.gbl...
When you look at the log file, are you opening it for read or for write?

--

Best regards,

Carlos J. Quintero

MZ-Tools: Productivity add-ins for Visual Studio .NET, VB6, VB5 and VBA
You can code, design and document much faster.
Free resources for add-in developers:
http://www.mztools.com

"Drew" <dr********@NOswvtc.dmhmrsas.virginia.SPMgov> escribió en el
mensaje news:Oy**************@TK2MSFTNGP10.phx.gbl...
I have a small VB.NET application that captures left clicks, right clicks
and key presses and automatically logs them to a csv file every 1 minute.
The issue is that if I want to look at the log file, I get an error
because the app is trying to write to the log file and it is open.

How can I circumvent this issue?

Thanks,
Drew


Nov 21 '05 #4

P: n/a
Hello Drew,

How are you doing?

Two ways to get out of this problem:
1) Copy the file and then open the copied file.
2) Create your own File reader in which you open a connection to the text
file in a ReadOnly mode.
And for this open a filestream instead. You can pass
System.IO.FileAccess.Read to the constructor.
Then you can create a new streamreader to read from the stream.

I hope this is helpful.

Thanks
Mona
[Grapecity]
"Drew" <dr********@NOswvtc.dmhmrsas.virginia.SPMgov> wrote in message
news:Oy**************@TK2MSFTNGP10.phx.gbl...
I have a small VB.NET application that captures left clicks, right clicks
and key presses and automatically logs them to a csv file every 1 minute.
The issue is that if I want to look at the log file, I get an error because the app is trying to write to the log file and it is open.

How can I circumvent this issue?

Thanks,
Drew

Nov 21 '05 #5

P: n/a
Basically, you should not open the file to view it with an *editor*, which
by definition will open the file for write. If you don´t find a tool that
can open a file to view it with read-only access, you can build your own.
The .NET framework has functions to open streams for read-only access. See
the docs about the Stream and derived classes.

--

Best regards,

Carlos J. Quintero

MZ-Tools: Productivity add-ins for Visual Studio .NET, VB6, VB5 and VBA
You can code, design and document much faster.
Free resources for add-in developers:
http://www.mztools.com
"Drew" <dr********@NOswvtc.dmhmrsas.virginia.SPMgov> escribió en el mensaje
news:OZ*************@TK2MSFTNGP10.phx.gbl...
I am opening it in Notepad, so I guess that I am opening it for writing...
How should I review this log while the program is running?

Do you want me to post all the code?

Thanks,
Drew


Nov 21 '05 #6

P: n/a
Thank you for your reply. I will check out the functions that you mentioned
and see what I can do.

Thanks,
Drew

"Carlos J. Quintero [VB MVP]" <ca*****@NOSPAMsogecable.com> wrote in message
news:O8**************@TK2MSFTNGP14.phx.gbl...
Basically, you should not open the file to view it with an *editor*, which
by definition will open the file for write. If you don´t find a tool that
can open a file to view it with read-only access, you can build your own.
The .NET framework has functions to open streams for read-only access. See
the docs about the Stream and derived classes.

--

Best regards,

Carlos J. Quintero

MZ-Tools: Productivity add-ins for Visual Studio .NET, VB6, VB5 and VBA
You can code, design and document much faster.
Free resources for add-in developers:
http://www.mztools.com
"Drew" <dr********@NOswvtc.dmhmrsas.virginia.SPMgov> escribió en el
mensaje news:OZ*************@TK2MSFTNGP10.phx.gbl...
I am opening it in Notepad, so I guess that I am opening it for writing...
How should I review this log while the program is running?

Do you want me to post all the code?

Thanks,
Drew

Nov 21 '05 #7

P: n/a
Thanks for your reply Mona, I will check out the suggested options and see
what I can find.

Thanks,
Drew

"Mona" <mo**@discussions.com> wrote in message
news:ur**************@TK2MSFTNGP12.phx.gbl...
Hello Drew,

How are you doing?

Two ways to get out of this problem:
1) Copy the file and then open the copied file.
2) Create your own File reader in which you open a connection to the text
file in a ReadOnly mode.
And for this open a filestream instead. You can pass
System.IO.FileAccess.Read to the constructor.
Then you can create a new streamreader to read from the stream.

I hope this is helpful.

Thanks
Mona
[Grapecity]
"Drew" <dr********@NOswvtc.dmhmrsas.virginia.SPMgov> wrote in message
news:Oy**************@TK2MSFTNGP10.phx.gbl...
I have a small VB.NET application that captures left clicks, right clicks
and key presses and automatically logs them to a csv file every 1 minute.
The issue is that if I want to look at the log file, I get an error

because
the app is trying to write to the log file and it is open.

How can I circumvent this issue?

Thanks,
Drew


Nov 21 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.