473,491 Members | 1,917 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Check Files

Hi, I need to check that 4 access database files exist and they are not in
use before I can process them.

For example say my files are:

C:\test\data1.mdb
C:\test\data2.mdb
C:\test\data3.mdb
C:\test\data4.mdb

I can use if (File.Exists(dbName)) on each one but is there a more generic
way of doing this with a method, an array or looping through them.

Basically I'm looking to check the files exist, if not show a message
reporting which file is missing. Also, check that the files are not open,
then again show a message if they are. The message will need to ask the user
if they want to carry on processing the other databases or cancel the whole
thing.

Thanks


Nov 16 '05 #1
1 1527
Use DirectoryInfo.GetFiles(), there's an overload that will take a search
pattern ("data*.mdb") and return an array of files, then just loop through
the files returned, looking for gaps.

"jez123456" <je*******@discussions.microsoft.com> wrote in message
news:66**********************************@microsof t.com...
Hi, I need to check that 4 access database files exist and they are not in
use before I can process them.

For example say my files are:

C:\test\data1.mdb
C:\test\data2.mdb
C:\test\data3.mdb
C:\test\data4.mdb

I can use if (File.Exists(dbName)) on each one but is there a more generic
way of doing this with a method, an array or looping through them.

Basically I'm looking to check the files exist, if not show a message
reporting which file is missing. Also, check that the files are not open,
then again show a message if they are. The message will need to ask the
user
if they want to carry on processing the other databases or cancel the
whole
thing.

Thanks

Nov 16 '05 #2

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

Similar topics

2
3494
by: David Fickbohm | last post by:
People, I am trying to determine the creation date of files in a folder. I am using the following code to find the folder and confirm that files exist in the folder. If someone could give me an...
5
2767
by: Dale Ring | last post by:
Access 2000 I need to check a particular folder for files of a particular type (such as *.txt) Prior to the next step. If Files of said type are present, then the code will continue, else it...
2
1695
by: Ed Eichman | last post by:
Hi Guys, When I create an ASP.NET web app, which files do I need to check into my version control? I assume that the "bin" directory is skipped, but I'm not sure about the hidden directories...
5
20250
by: cmay | last post by:
The only examples I have seen on how to check if a file is locked is to try to open it a catch an exception. MS has stated that you should never use error trapping in this manner. Is there no...
6
39910
by: Fred W. | last post by:
When my application starts I need to check folder permissions to ensure they have "Full Control" before I let them proceed on. How can I check this permission. Thank you, Fred
6
34617
by: Ros | last post by:
There are 10 files in the folder. I wish to process all the files one by one. But if the files are open or some processing is going on them then I do not want to disturb that process. In that case...
3
2914
by: Beliavsky | last post by:
A crude way to check if two files are the same on Windows is to look at the output of the "fc" function of cmd.exe, for example def files_same(f1,f2): cmnd = "fc " + f1 + " " + f2 return...
4
2623
by: giftson.john | last post by:
Hi, I am creating an application which migrates all documents from one repository to another repository. Before migration i have to verify all the documents are unique. No duplicates has to be...
2
1872
by: =?Utf-8?B?Umljaw==?= | last post by:
I am looking for some suggestions from the group on Source Safe. 1. What is the best practice/rule for the Source Safe to check-out and check-in files for a small group of developers? 2. ...
0
7118
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
1
6862
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
7364
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
5452
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,...
1
4886
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4579
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3087
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3078
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1397
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.