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

File Lock Discovery

Hi all,

Does anybody know a way, in VB.Net, I can discover the file locks on a file
on the local machine. I have an application which needs to delete specific
files, but I would like to verify in advance whether or not a particular
deletion will succeed. Due to other pre-deletion actions, I cannot attempt
the deletion and catch the exception if it fails.

Thanks in advance

Justin
Jul 21 '05 #1
2 1810
Hi, Justin

As locks are dynamic in such cases your best bet would be to use try/catch
around the code. I am not sure I can see why pre-delete actions are not
allowing you to use this simple and efficient approach. Would you care to
explain?

HTH
Alex

"Justin" <ju****@discussions.microsoft.com> wrote in message
news:uC**************@TK2MSFTNGP09.phx.gbl...
Hi all,

Does anybody know a way, in VB.Net, I can discover the file locks on a file on the local machine. I have an application which needs to delete specific
files, but I would like to verify in advance whether or not a particular
deletion will succeed. Due to other pre-deletion actions, I cannot attempt
the deletion and catch the exception if it fails.

Thanks in advance

Justin

Jul 21 '05 #2
Hi Alex,

Thanks for your reply.

The reason I wanted to 'pre-validate' the deletion is because I need to unregister the file for COM, prior to deletion. If I do not do this and the deletion succeeds I have missed my opportunity to do the unregistration. So I unregister and try to delete, if the deletion fails I have an 'undo' process that re-registers the file.

This solution does work. I had just wondered if there was a straight forward way of checking, prior to deletion. If, as it appears, there is not then so be it, I will stick to the solution I have.

Thanks

Justin
"AlexS" wrote:
Hi, Justin

As locks are dynamic in such cases your best bet would be to use try/catch
around the code. I am not sure I can see why pre-delete actions are not
allowing you to use this simple and efficient approach. Would you care to
explain?

HTH
Alex

"Justin" <ju****@discussions.microsoft.com> wrote in message
news:uC**************@TK2MSFTNGP09.phx.gbl...
Hi all,

Does anybody know a way, in VB.Net, I can discover the file locks on a

file
on the local machine. I have an application which needs to delete specific
files, but I would like to verify in advance whether or not a particular
deletion will succeed. Due to other pre-deletion actions, I cannot attempt
the deletion and catch the exception if it fails.

Thanks in advance

Justin


Jul 21 '05 #3

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

Similar topics

6
by: Pekka Niiranen | last post by:
Hi, I have used the following example from win32 extensions: -----SCRIPT STARTS---- import win32file import win32con import win32security import pywintypes
0
by: Anurag | last post by:
Hi, I understand that the dbm cfg parameter "DISCOVER" controls whether Search or Known discovery is applicable. Additionally, Search discovery provides a superset of Known discovery. I completely...
8
by: Stephen Corey | last post by:
I'm writing an app that basically just appends text to a text file on a Win2K Server. They fill out a form, click a button, and 1 line is appended to the file. Multiple people will run this app at...
6
by: martin | last post by:
Hi, I have noticed that every aspx page that I created (and ascx file) has an assosiated resource file aspx.resx. However what I would like to do is have a single global resource file for the...
2
by: Justin | last post by:
Hi all, Does anybody know a way, in VB.Net, I can discover the file locks on a file on the local machine. I have an application which needs to delete specific files, but I would like to verify...
3
by: Matt D | last post by:
I've got two web services that use the same data types and that clients will have to consume. I read the msdn article on sharing types...
1
by: ABCL | last post by:
Hi All, I am working on the situation where 2 different Process/Application(.net) tries to open file at the same time....Or one process is updating the file and another process tries to access...
7
by: Chris Mullins | last post by:
I'm in the process of building a number of (Web) Services using .NET 3.0 and WCF. These services are intended to be deployed within the Intranet of a very, very large orginization. I need to...
0
by: news.microsoft.com | last post by:
Hey All, Sorry to post to several groups but wasn't sure which development group would be best for the question. I was wondering if there are any developers out there that have significant...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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.