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

How to 'lock' a file?

nvx
Hi,
I have an application working with an Access database and I need to
'lock' the currently opened DB file in order to prevent it to be
deleted, modified by other applications etc. Does anyone know how to
achieve this? An information regarding unlocking a file would also be
appreciated.

Thanks for any help...

Regards
nvx

Jun 29 '06 #1
7 1969
On 29 Jun 2006 06:16:33 -0700, nvx wrote:
Hi,
I have an application working with an Access database and I need to
'lock' the currently opened DB file in order to prevent it to be
deleted, modified by other applications etc. Does anyone know how to
achieve this? An information regarding unlocking a file would also be
appreciated.


Usually, methods that allow you to open a file provide you with the option
of passing a FileShare argument letting you specify whether or not you want
to allow other processes to have read or write access to your file while
you have it open. Have a look at the doc for FileShare. The File.Open()
method for example accept a FileShare argument. If you choose not to let
other processes have access to your file while you are having it open, you
can remove this "lock" simply by closing the file.

I'm not sure what happens in the particular case of an Access file. I seem
to remember from the time we were using Access for our database that you
can specify in the connection string what type of file sharing you want.
Jun 29 '06 #2
nvx
Thank you very much for your time. I briefly checked the DB file
properties in my VC# Express Edition and found nothing similar. It is
probably caused by the version of VS, but I'm not sure. I'll try to
google this 'FileShare' thing to find out more...

Regards
nvx
Mehdi napsal:
On 29 Jun 2006 06:16:33 -0700, nvx wrote:
Hi,
I have an application working with an Access database and I need to
'lock' the currently opened DB file in order to prevent it to be
deleted, modified by other applications etc. Does anyone know how to
achieve this? An information regarding unlocking a file would also be
appreciated.


Usually, methods that allow you to open a file provide you with the option
of passing a FileShare argument letting you specify whether or not you want
to allow other processes to have read or write access to your file while
you have it open. Have a look at the doc for FileShare. The File.Open()
method for example accept a FileShare argument. If you choose not to let
other processes have access to your file while you are having it open, you
can remove this "lock" simply by closing the file.

I'm not sure what happens in the particular case of an Access file. I seem
to remember from the time we were using Access for our database that you
can specify in the connection string what type of file sharing you want.


Jun 30 '06 #3
Hello nvx,
I did a quick google and found that you can specify Exclusive in the
connection string.
http://www.google.com/search?hl=en&q...nection+String
Good Luck,
Mark

"nvx" wrote:
Thank you very much for your time. I briefly checked the DB file
properties in my VC# Express Edition and found nothing similar. It is
probably caused by the version of VS, but I'm not sure. I'll try to
google this 'FileShare' thing to find out more...

Regards
nvx
Mehdi napsal:
On 29 Jun 2006 06:16:33 -0700, nvx wrote:
Hi,
I have an application working with an Access database and I need to
'lock' the currently opened DB file in order to prevent it to be
deleted, modified by other applications etc. Does anyone know how to
achieve this? An information regarding unlocking a file would also be
appreciated.


Usually, methods that allow you to open a file provide you with the option
of passing a FileShare argument letting you specify whether or not you want
to allow other processes to have read or write access to your file while
you have it open. Have a look at the doc for FileShare. The File.Open()
method for example accept a FileShare argument. If you choose not to let
other processes have access to your file while you are having it open, you
can remove this "lock" simply by closing the file.

I'm not sure what happens in the particular case of an Access file. I seem
to remember from the time we were using Access for our database that you
can specify in the connection string what type of file sharing you want.


Jun 30 '06 #4
nvx
Thank you very much... :) That seems to be the exact thing I need... I
really appreciate your effort. Since I'm a newbie I don't know the
proper keywords to search for.

Regards
nvx
MarkTheNuke napsal:
Hello nvx,
I did a quick google and found that you can specify Exclusive in the
connection string.
http://www.google.com/search?hl=en&q...nection+String
Good Luck,
Mark

"nvx" wrote:
Thank you very much for your time. I briefly checked the DB file
properties in my VC# Express Edition and found nothing similar. It is
probably caused by the version of VS, but I'm not sure. I'll try to
google this 'FileShare' thing to find out more...

Regards
nvx
Mehdi napsal:
On 29 Jun 2006 06:16:33 -0700, nvx wrote:

> Hi,
> I have an application working with an Access database and I need to
> 'lock' the currently opened DB file in order to prevent it to be
> deleted, modified by other applications etc. Does anyone know how to
> achieve this? An information regarding unlocking a file would also be
> appreciated.

Usually, methods that allow you to open a file provide you with the option
of passing a FileShare argument letting you specify whether or not you want
to allow other processes to have read or write access to your file while
you have it open. Have a look at the doc for FileShare. The File.Open()
method for example accept a FileShare argument. If you choose not to let
other processes have access to your file while you are having it open, you
can remove this "lock" simply by closing the file.

I'm not sure what happens in the particular case of an Access file. I seem
to remember from the time we were using Access for our database that you
can specify in the connection string what type of file sharing you want.



Jun 30 '06 #5
nvx
Thank you very much... :) That seems to be the exact thing I need... I
really appreciate your effort. Since I'm a newbie I don't know the
proper keywords to search for.

Regards
nvx
MarkTheNuke napsal:
Hello nvx,
I did a quick google and found that you can specify Exclusive in the
connection string.
http://www.google.com/search?hl=en&q...nection+String
Good Luck,
Mark

"nvx" wrote:
Thank you very much for your time. I briefly checked the DB file
properties in my VC# Express Edition and found nothing similar. It is
probably caused by the version of VS, but I'm not sure. I'll try to
google this 'FileShare' thing to find out more...

Regards
nvx
Mehdi napsal:
On 29 Jun 2006 06:16:33 -0700, nvx wrote:

> Hi,
> I have an application working with an Access database and I need to
> 'lock' the currently opened DB file in order to prevent it to be
> deleted, modified by other applications etc. Does anyone know how to
> achieve this? An information regarding unlocking a file would also be
> appreciated.

Usually, methods that allow you to open a file provide you with the option
of passing a FileShare argument letting you specify whether or not you want
to allow other processes to have read or write access to your file while
you have it open. Have a look at the doc for FileShare. The File.Open()
method for example accept a FileShare argument. If you choose not to let
other processes have access to your file while you are having it open, you
can remove this "lock" simply by closing the file.

I'm not sure what happens in the particular case of an Access file. I seem
to remember from the time we were using Access for our database that you
can specify in the connection string what type of file sharing you want.



Jun 30 '06 #6
nvx
Thank you very much... :) That seems to be the exact thing I need... I
really appreciate your effort. Since I'm a newbie I don't know the
proper keywords to search for.

Regards
nvx
MarkTheNuke napsal:
Hello nvx,
I did a quick google and found that you can specify Exclusive in the
connection string.
http://www.google.com/search?hl=en&q...nection+String
Good Luck,
Mark

"nvx" wrote:
Thank you very much for your time. I briefly checked the DB file
properties in my VC# Express Edition and found nothing similar. It is
probably caused by the version of VS, but I'm not sure. I'll try to
google this 'FileShare' thing to find out more...

Regards
nvx
Mehdi napsal:
On 29 Jun 2006 06:16:33 -0700, nvx wrote:

> Hi,
> I have an application working with an Access database and I need to
> 'lock' the currently opened DB file in order to prevent it to be
> deleted, modified by other applications etc. Does anyone know how to
> achieve this? An information regarding unlocking a file would also be
> appreciated.

Usually, methods that allow you to open a file provide you with the option
of passing a FileShare argument letting you specify whether or not you want
to allow other processes to have read or write access to your file while
you have it open. Have a look at the doc for FileShare. The File.Open()
method for example accept a FileShare argument. If you choose not to let
other processes have access to your file while you are having it open, you
can remove this "lock" simply by closing the file.

I'm not sure what happens in the particular case of an Access file. I seem
to remember from the time we were using Access for our database that you
can specify in the connection string what type of file sharing you want.



Jun 30 '06 #7
nvx
Uh... I guess something went wrong here... :)
nvx napsal:
Thank you very much... :) That seems to be the exact thing I need... I
really appreciate your effort. Since I'm a newbie I don't know the
proper keywords to search for.

Regards
nvx
MarkTheNuke napsal:
Hello nvx,
I did a quick google and found that you can specify Exclusive in the
connection string.
http://www.google.com/search?hl=en&q...nection+String
Good Luck,
Mark

"nvx" wrote:
Thank you very much for your time. I briefly checked the DB file
properties in my VC# Express Edition and found nothing similar. It is
probably caused by the version of VS, but I'm not sure. I'll try to
google this 'FileShare' thing to find out more...

Regards
nvx
Mehdi napsal:
> On 29 Jun 2006 06:16:33 -0700, nvx wrote:
>
> > Hi,
> > I have an application working with an Access database and I need to
> > 'lock' the currently opened DB file in order to prevent it to be
> > deleted, modified by other applications etc. Does anyone know how to
> > achieve this? An information regarding unlocking a file would also be
> > appreciated.
>
> Usually, methods that allow you to open a file provide you with the option
> of passing a FileShare argument letting you specify whether or not you want
> to allow other processes to have read or write access to your file while
> you have it open. Have a look at the doc for FileShare. The File.Open()
> method for example accept a FileShare argument. If you choose not to let
> other processes have access to your file while you are having it open, you
> can remove this "lock" simply by closing the file.
>
> I'm not sure what happens in the particular case of an Access file. I seem
> to remember from the time we were using Access for our database that you
> can specify in the connection string what type of file sharing you want.


Jun 30 '06 #8

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

Similar topics

14
by: Antoon Pardon | last post by:
The queue and condition class allow threads to wait only a limited time. However this currently is implemented by a polling loop. Now for those who like to avoid polling I have here a Tlock...
0
by: John | last post by:
I've got multiple threads and processes that write to same file. Before writing all threads / processes first lock part of file and then write to file. If one thread / process locks file, another...
7
by: John Bailo | last post by:
I'm seeing some odd locking behavior when using an DB2400 database and running an ado.net transaction. My code -- in simplified form, appears at the bottom. I want to run several INSERT...
0
by: John Bailo | last post by:
I'm seeing some odd locking behavior when using an DB2400 database and running an ado.net transaction. My code -- in simplified form, appears at the bottom. I want to run several INSERT...
0
by: Andrew Dowding | last post by:
Hi Everybody, I have been looking at problems with my Windows Forms C# application and it's little Jet 4 (Access) database for the last few days. The Windows Forms app implements a facade and...
14
by: Gary Nelson | last post by:
Anyone have any idea why this code does not work? FileOpen(1, "c:\JUNK\MYTEST.TXT", OpenMode.Binary, OpenAccess.ReadWrite, OpenShare.Shared) Dim X As Integer For X = 1 To 26 FilePut(1, Chr(X +...
4
by: muttu2244 | last post by:
hi all am trying to write some information into the file, which is located in ftp, and this file can be updated by number of people, but if at all i download a file from the ftp to my local...
12
by: Elmo Mäntynen | last post by:
Is there something better than using fnctl? It seems a bit intimidating with a quick look.
5
by: pgdown | last post by:
Hi, I have several processes accessing files from one folder, but only one process should ever access each file. Once one process has the file, no other process should be allowed to access it,...
2
by: WingSiu | last post by:
I am writing a Logging util for my ASP.NET application. I am facing mulit process problem. I developed a class LogFactory, and have a method called Get_Logger to create a FileLogger, which will...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.