?
Solved

VB.NET - How to determine if a file is in use?

Posted on 2009-04-15
6
Medium Priority
?
159 Views
Last Modified: 2012-05-06
I can test if a file exists by using System.IO.File.Exists(filename), but how can I test for:

1) a file in use?

2) username using the file?

Thank you.
0
Comment
Question by:Tom Sage
  • 3
  • 3
6 Comments
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 24151458
1. Try to open the file in Append mode.

0
 

Author Comment

by:Tom Sage
ID: 24151495
Would you give me a short example please?

Thanks
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 24151631
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

Author Comment

by:Tom Sage
ID: 24151691
Eric,
Thanks for your response.  

I was wondering if .NET had the ability to report on a file in use and who is using it without having to create an exception to get the information.  If not, then we will get it from the exception.

Thank you
0
 
LVL 70

Accepted Solution

by:
Éric Moreau earned 2000 total points
ID: 24151730
>>I was wondering if .NET had the ability to report on a file in use

No. It doesn't try to retreive that information until it really has to. This occurs only when it tries to open it.

>>and who is using it

I have never seen this information available from a .Net application
0
 

Author Closing Comment

by:Tom Sage
ID: 31570626
Eric, thanks for your prompt response.  Too bad .NET doesnt supply this without having to create an exception.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses
Course of the Month14 days, 14 hours left to enroll

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question