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

File being used

P: n/a


Do you have any idea of how I can find out if a file in a
directory is being used by a user or application without
trying to open/delete/... the file? (Just getting the
file status)
It would be highly appreciated if you reply me.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 20 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Cor
Do you have any idea of how I can find out if a file in a
directory is being used by a user or application without
trying to open/delete/... the file? (Just getting the
file status)


Did you look at the fileinfo class?
I don't see any information in the attributes about "used".
But why are you not doing after evaluating the attribute information a
\\
try
'open does not matter how a file
catch ex as exeption
'check the exeption
finally
'close file
end try
///
I hope this helps a little bit
Cor

Nov 20 '05 #2

P: n/a
Hello,

"Cor" <no*@non.com> schrieb:
Did you look at the fileinfo class?
I don't see any information in the attributes about "used".
But why are you not doing after evaluating the attribute
information a
\\
try
'open does not matter how a file
catch ex as exeption
'check the exeption
finally
'close file
end try
///
I hope this helps a little bit


There is a _little_ problem: If the file is not used by an other
application, opening it may change the file date (last access).

;-)

--
Herfried K. Wagner
MVP VB Classic, VB.NET
http://www.mvps.org/dotnet
Nov 20 '05 #3

P: n/a
Cor
Herfried,
This did remind me on a promise I did make last night.
I putted it by the notepad thread,
Then I thought why not test what Herfried said (normaly I don't do that), it
was in one route,
but I was busy with the other things, and I think Fergus and I are both very
quick typers.
Here it is, test it if you want after you did the other one, then the file
is on disk.
\\\\
Dim sr As StreamReader
Dim a As New FileInfo("C:\Armin")
Try
sr = New StreamReader("C:\Armin")
Finally
sr.Close()
End Try

Threading.Thread.Sleep(10000)
Dim b As New FileInfo("C:\Armin")
MessageBox.Show(a.LastAccessTime.ToString & "|" &
b.LastAccessTime.ToString)
////
But you know of course the answer already.

:-))

Or maybe I have another computer than you.
Cor

PS, I left that Doornbos thing for you, yesterday, you said only "NO" so I
thought now you would say only "YES"
:-))
Nov 20 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.