473,385 Members | 1,813 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,385 software developers and data experts.

File Share Question

In an application in which FileShare is set.
Is it possible to go to say a file conntrol block
to ascertain the condition of the file, ie. if
someone else is working with the file? Or is
is it necessary to do all writing (not reading)
in a loop in which the user is kept till the
file is free again?

Adrian.
Nov 14 '06 #1
10 1238
"Adrian <" <no*@all.accessiblewrote in news:45599e79$0$749$5fc3050
@dreader2.news.tiscali.nl:
In an application in which FileShare is set.
Is it possible to go to say a file conntrol block
to ascertain the condition of the file, ie. if
someone else is working with the file? Or is
is it necessary to do all writing (not reading)
in a loop in which the user is kept till the
file is free again?

I believe if your filestream remains open - and depending on which mode you
have the filestream set to, you'll have control over the file.

Nov 15 '06 #2

"Spam Catcher" <sp**********@rogers.comwrote in message
news:Xn**********************************@127.0.0. 1...
"Adrian <" <no*@all.accessiblewrote in news:45599e79$0$749$5fc3050
@dreader2.news.tiscali.nl:
In an application in which FileShare is set.
Is it possible to go to say a file conntrol block
to ascertain the condition of the file, ie. if
someone else is working with the file? Or is
is it necessary to do all writing (not reading)
in a loop in which the user is kept till the
file is free again?

Hi,

If a FileShare parameter is used and a
file is opened permitting others to read only,
what happens if some one tries to modify
the file, will he be set to wait in a loop
or will he get an error message?

Adrian.


Nov 15 '06 #3
I believe the .NEt framework will throw an exception if you try and open a
file for writing that has been opened elswjere for read only

--
Bits. Bytes.
http://bytes.thinkersroom.com
------------------------------
Hi,

If a FileShare parameter is used and a
file is opened permitting others to read only,
what happens if some one tries to modify
the file, will he be set to wait in a loop
or will he get an error message?

Adrian.


Nov 15 '06 #4
"Adrian <" <no*@all.accessiblewrote in news:455af913$0$750$5fc3050
@dreader2.news.tiscali.nl:
If a FileShare parameter is used and a
file is opened permitting others to read only,
what happens if some one tries to modify
the file, will he be set to wait in a loop
or will he get an error message?
..NET will throw an exception.
Nov 15 '06 #5
Ok, thanks.
I think I have soved the problem by adding
code like so:

While(!fs.CanRead){}

That will keep the user waiting just a little
while till the file is free again. At least,
that is my expectation :)

(For the non-filestream files I have written
a simple block / unblock routine.)

Thank you again

Adrian.
"Spam Catcher" <sp**********@rogers.comwrote in message
news:Xn**********************************@127.0.0. 1...
"Adrian <" <no*@all.accessiblewrote in news:455af913$0$750$5fc3050
@dreader2.news.tiscali.nl:
If a FileShare parameter is used and a
file is opened permitting others to read only,
what happens if some one tries to modify
the file, will he be set to wait in a loop
or will he get an error message?

.NET will throw an exception.

Nov 15 '06 #6
Hi Adrian,

You might want to let some other threads get some processor time as well by
putting the thread to sleep:

while (!fs.CanRead)
{
System.Threading.Thread.Current.Sleep(200);
}

--
Dave Sexton

"Adrian <" <no*@all.accessiblewrote in message
news:45********************@dreader2.news.tiscali. nl...
Ok, thanks.
I think I have soved the problem by adding
code like so:

While(!fs.CanRead){}

That will keep the user waiting just a little
while till the file is free again. At least,
that is my expectation :)

(For the non-filestream files I have written
a simple block / unblock routine.)

Thank you again

Adrian.
"Spam Catcher" <sp**********@rogers.comwrote in message
news:Xn**********************************@127.0.0. 1...
>"Adrian <" <no*@all.accessiblewrote in news:455af913$0$750$5fc3050
@dreader2.news.tiscali.nl:
If a FileShare parameter is used and a
file is opened permitting others to read only,
what happens if some one tries to modify
the file, will he be set to wait in a loop
or will he get an error message?

.NET will throw an exception.


Nov 17 '06 #7
"Dave Sexton" <dave@jwa[remove.this]online.comwrote in message
news:ep**************@TK2MSFTNGP06.phx.gbl...
Hi Adrian,

You might want to let some other threads get some processor time as well
by
putting the thread to sleep:

while (!fs.CanRead)
{
System.Threading.Thread.Current.Sleep(200);
}
*********************************
That is good advice, Thank you for it.
Adrian.
Nov 17 '06 #8
Your suggestion generated an error.
("... cannot be accessed as an instance reference ...")
Would System.Threading.Thread.Sleep(200);
be ok as well?

Please advise.

Adrian.


"Dave Sexton" <dave@jwa[remove.this]online.comwrote in message
news:ep**************@TK2MSFTNGP06.phx.gbl...
Hi Adrian,

You might want to let some other threads get some processor time as well
by
putting the thread to sleep:

while (!fs.CanRead)
{
System.Threading.Thread.Current.Sleep(200);
}

--
Dave Sexton

"Adrian <" <no*@all.accessiblewrote in message
news:45********************@dreader2.news.tiscali. nl...
Ok, thanks.
I think I have soved the problem by adding
code like so:

While(!fs.CanRead){}

That will keep the user waiting just a little
while till the file is free again. At least,
that is my expectation :)

(For the non-filestream files I have written
a simple block / unblock routine.)

Thank you again

Adrian.
"Spam Catcher" <sp**********@rogers.comwrote in message
news:Xn**********************************@127.0.0. 1...
"Adrian <" <no*@all.accessiblewrote in news:455af913$0$750$5fc3050
@dreader2.news.tiscali.nl:

If a FileShare parameter is used and a
file is opened permitting others to read only,
what happens if some one tries to modify
the file, will he be set to wait in a loop
or will he get an error message?

.NET will throw an exception.


Nov 17 '06 #9
Hi,

Yes, sorry. I wrote that off the top of my head, which apparently is the
stupid part ;)

--
Dave Sexton

"Adrian <" <no*@all.accessiblewrote in message
news:45********************@dreader2.news.tiscali. nl...
Your suggestion generated an error.
("... cannot be accessed as an instance reference ...")
Would System.Threading.Thread.Sleep(200);
be ok as well?

Please advise.

Adrian.


"Dave Sexton" <dave@jwa[remove.this]online.comwrote in message
news:ep**************@TK2MSFTNGP06.phx.gbl...
>Hi Adrian,

You might want to let some other threads get some processor time as well
by
>putting the thread to sleep:

while (!fs.CanRead)
{
System.Threading.Thread.Current.Sleep(200);
}

--
Dave Sexton

"Adrian <" <no*@all.accessiblewrote in message
news:45********************@dreader2.news.tiscali .nl...
Ok, thanks.
I think I have soved the problem by adding
code like so:

While(!fs.CanRead){}

That will keep the user waiting just a little
while till the file is free again. At least,
that is my expectation :)

(For the non-filestream files I have written
a simple block / unblock routine.)

Thank you again

Adrian.
"Spam Catcher" <sp**********@rogers.comwrote in message
news:Xn**********************************@127.0.0. 1...
"Adrian <" <no*@all.accessiblewrote in news:455af913$0$750$5fc3050
@dreader2.news.tiscali.nl:

If a FileShare parameter is used and a
file is opened permitting others to read only,
what happens if some one tries to modify
the file, will he be set to wait in a loop
or will he get an error message?

.NET will throw an exception.




Nov 17 '06 #10
:))

Adian

"Dave Sexton" <dave@jwa[remove.this]online.comwrote in message
news:OH**************@TK2MSFTNGP02.phx.gbl...
Hi,

Yes, sorry. I wrote that off the top of my head, which apparently is the
stupid part ;)

--
Dave Sexton

"Adrian <" <no*@all.accessiblewrote in message
news:45********************@dreader2.news.tiscali. nl...
Your suggestion generated an error.
("... cannot be accessed as an instance reference ...")
Would System.Threading.Thread.Sleep(200);
be ok as well?

Please advise.

Adrian.


"Dave Sexton" <dave@jwa[remove.this]online.comwrote in message
news:ep**************@TK2MSFTNGP06.phx.gbl...
Hi Adrian,

You might want to let some other threads get some processor time as
well
by
putting the thread to sleep:

while (!fs.CanRead)
{
System.Threading.Thread.Current.Sleep(200);
}

--
Dave Sexton

"Adrian <" <no*@all.accessiblewrote in message
news:45********************@dreader2.news.tiscali. nl...
Ok, thanks.
I think I have soved the problem by adding
code like so:

While(!fs.CanRead){}

That will keep the user waiting just a little
while till the file is free again. At least,
that is my expectation :)

(For the non-filestream files I have written
a simple block / unblock routine.)

Thank you again

Adrian.
"Spam Catcher" <sp**********@rogers.comwrote in message
news:Xn**********************************@127.0.0. 1...
"Adrian <" <no*@all.accessiblewrote in
news:455af913$0$750$5fc3050
@dreader2.news.tiscali.nl:

If a FileShare parameter is used and a
file is opened permitting others to read only,
what happens if some one tries to modify
the file, will he be set to wait in a loop
or will he get an error message?

.NET will throw an exception.





Nov 17 '06 #11

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

Similar topics

2
by: vince | last post by:
MSDN help says you can use a UNC path for any methods that accept a path, and I'm wondering if I can also substitute an IP address for the UNC....??? Example: Using System.IO.File.Move() ...
4
by: Rene' Nielsen | last post by:
Context: Running Windows 2003 Server on an intranet. A web is configured with an anonymous access account that is a domain account that has been granted the desired access to a file on another...
0
by: serge calderara | last post by:
Dear all, I am buildiing an application that will run from a network share. That application is using a configuration file with different settings, from myApp.exe.config. For lient computer,...
18
by: Andre Laplume via AccessMonster.com | last post by:
I have inherited a bunch of dbs which are are shared among a small group in my dept. We typically use the dbs to write queries to extract data, usually dumping it into Excel. Most dbs originated...
3
by: thxBruin | last post by:
I have a Class CTest in test.cs but two or more projects need this class. So how to share the SOURCE FILE(test.cs, not using dll file) in these projects?
4
by: Jason Hurder | last post by:
Hello folks, I am experiencing a rather strange problem. I have written a service that attempts to open a file on a network share via a FileStream object. When I try to open the file from my...
7
by: Frank Rizzo | last post by:
Hello, I've asked this question in the languages.vb group, but got no response, so I'll try my luck here. My app needs to copy a file from a local folder to a network share. The network share...
5
by: Washington | last post by:
Is possible to copy file from some server for. e.g. brinkster to computer (on specified location) programmatically? I am trying to make some automatic update of my application... Thanks :)
2
by: Miro | last post by:
I will ask the question first then fumble thru trying to explain myself so i dont waste too much of your time. Question / Statement - Every mdb table needs a PrimaryKey ( or maybe an index - i...
14
by: alexus | last post by:
Hello, I have bunch of video files, and I need somehow alternate them, and by that I mean so check sum would be different, yet won't break content of video itself. any ideas?
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...

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.