473,397 Members | 2,056 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,397 software developers and data experts.

VSNet 2005 service works as expected, except for my computer being too fast/lazy ?

Hi. I have created a service which watches a folder and if any text
file is added to that folder runs a custom encryption scheme on it. I
add a file in that folder, and it works fine. However, when I add a
second file I have a run-time error on my "openfile" line, saying that
the file is in use by another process (of course, Explorer, which I use
to copy the file in the watched folder). The same thing happens when I
copy a series of files to that folder. If I attach to that process and
I spent a second in the debugger on the line that triggers the error,
without changing anything, and then continue (F5), everything runs fine
again with that file, which makes me believe that either Explorer does
not release the file handle fast enough, either the file watcher in my
service triggers too soon. I have added a Thread.Sleep(100) before the
starting on my encryption algorithm, but I really don't like this idea
- it's messy. Besides, even if it worked on my machine, on another
100ms might not be enough.

I could attempt to open that file several times, in a loop, with maybe
a timeout, but still, this is not elegant. Is there any (more elegant,
and cleaner) alternative, please ?

Thank you.
Alex.

Apr 7 '06 #1
2 1444
Your concept is VERY messy because you have no control over the file access
modes used by IE or any other application that might use in that directory.

If you encrypt the file that IE uses, IE will not longer able to use it? So
why would you do this? Are you try to manipulate cookies or something?

Anyway, might be able to open the file in a share access mode IF and ONLY IF
IE does not open the file in locked access mode. You'd have to dig deep
into the OS to remove IE's hold on a file (deeper than what .NET framework
will support).

"Radu" <cu*************@yahoo.com> wrote in message
news:11**********************@u72g2000cwu.googlegr oups.com...
Hi. I have created a service which watches a folder and if any text
file is added to that folder runs a custom encryption scheme on it. I
add a file in that folder, and it works fine. However, when I add a
second file I have a run-time error on my "openfile" line, saying that
the file is in use by another process (of course, Explorer, which I use
to copy the file in the watched folder). The same thing happens when I
copy a series of files to that folder. If I attach to that process and
I spent a second in the debugger on the line that triggers the error,
without changing anything, and then continue (F5), everything runs fine
again with that file, which makes me believe that either Explorer does
not release the file handle fast enough, either the file watcher in my
service triggers too soon. I have added a Thread.Sleep(100) before the
starting on my encryption algorithm, but I really don't like this idea
- it's messy. Besides, even if it worked on my machine, on another
100ms might not be enough.

I could attempt to open that file several times, in a loop, with maybe
a timeout, but still, this is not elegant. Is there any (more elegant,
and cleaner) alternative, please ?

Thank you.
Alex.

Apr 7 '06 #2
No, Rob, I certainly have no malicious intents - this is simply an exercise
that I'm doing, meant to teach me how to create a fully functional,
well-behaving service :-))

Thanks, Alex.

"Rob R. Ainscough" <ro*****@pacbell.net> wrote in message
news:O9**************@TK2MSFTNGP03.phx.gbl...
Your concept is VERY messy because you have no control over the file
access modes used by IE or any other application that might use in that
directory.

If you encrypt the file that IE uses, IE will not longer able to use it?
So why would you do this? Are you try to manipulate cookies or something?

Anyway, might be able to open the file in a share access mode IF and ONLY
IF IE does not open the file in locked access mode. You'd have to dig
deep into the OS to remove IE's hold on a file (deeper than what .NET
framework will support).

"Radu" <cu*************@yahoo.com> wrote in message
news:11**********************@u72g2000cwu.googlegr oups.com...
Hi. I have created a service which watches a folder and if any text
file is added to that folder runs a custom encryption scheme on it. I
add a file in that folder, and it works fine. However, when I add a
second file I have a run-time error on my "openfile" line, saying that
the file is in use by another process (of course, Explorer, which I use
to copy the file in the watched folder). The same thing happens when I
copy a series of files to that folder. If I attach to that process and
I spent a second in the debugger on the line that triggers the error,
without changing anything, and then continue (F5), everything runs fine
again with that file, which makes me believe that either Explorer does
not release the file handle fast enough, either the file watcher in my
service triggers too soon. I have added a Thread.Sleep(100) before the
starting on my encryption algorithm, but I really don't like this idea
- it's messy. Besides, even if it worked on my machine, on another
100ms might not be enough.

I could attempt to open that file several times, in a loop, with maybe
a timeout, but still, this is not elegant. Is there any (more elegant,
and cleaner) alternative, please ?

Thank you.
Alex.


Apr 7 '06 #3

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

Similar topics

22
by: edgrsprj | last post by:
PROPOSED EARTHQUAKE FORECASTING COMPUTER PROGRAM DEVELOPMENT EFFORT Posted July 11, 2005 My main earthquake forecasting Web page is: http://www.freewebz.com/eq-forecasting/Data.html ...
27
by: Richard Blewett [DevelopMentor] | last post by:
I've just seen on Eric Gunnerson's blog that C# is getting Edit and Continue in Whidbey. That will please alot of people - although me, I have mixed feelings about it ;-) ...
4
by: Greg P | last post by:
I know this is a long post, please bear with me. I have been working on this all weekend to no avail although I have done a good amount of research (see most pertinent links that I've looked at...
7
by: Greg P | last post by:
I know this is a long post, please bear with me. I have been working on this all weekend to no avail although I have done a good amount of research (see most pertinent links that I've looked at...
6
by: Joe | last post by:
C# .NET 2.0 I've got a Windows Service that works exactly as I expect it to. However, it does rely on a few Configuration settings. If the customer doesn't configure it correctly, the service...
1
by: thomas | last post by:
Hello all, I have a C# windows application project and a web service project, all part of the same solution. My windows application references and uses web service. Everything works as expected...
9
by: HC | last post by:
Hello, all, I started out thinking my problems were elsewhere but as I have worked through this I have isolated my problem, currently, as a difference between MSDE and SQL Express 2005 (I'll just...
0
by: fischermx | last post by:
Environment: Microsoft Visual Studio 2005 Version 8.0.50727.762 (SP.050727-7600) Microsoft .NET Framework Version 2.0.50727 Microsoft Visual Studio 2005 Professional Edition - ENU Service Pack...
2
by: Phillip B Oldham | last post by:
We're looking at the next phase of development for our webapp, and the main focus will be to move the core from the app to a web service so other systems can use the data we've gathered (we're...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.