ARTICLE

Locking Files in VB.NET

Posted by Vishal Kulkarni Articles | Visual Basic 2010 May 02, 2004
This code shows how to lock and unlock files. A locked file will not be opened unless it is unlocked. It can lock any type of file.
Download Files:
 
Reader Level:

Description :

This code locks and unlocks the any type of file. The file unless unlocked will not open.

API Description :

  1. CreateFile: This API owns the handle for the selected file.

  2. CloseHandle : This API returns the handle to the file to the system.

  3. LockFile : This API locks the file. Various constants can be tried out to study the API. 

General Description :

Run this code. Select the desired file to be locked. Now the program owns the file handle. Anything to the file can be done in the program as it exclusively has the handle. Now try to open the file .The file will not be opened. It will say the file is locked. Now to unlock the file click "Press ok to Unlock the file", the file will be unlocked and can be used normally.

Login to add your contents and source code to this article
share this article :
post comment
 

Hi! I used that code in vb.net 2008. but it didn't work at all. Please help.

Posted by Ravi Kant Dec 11, 2010

hello i want to ask that is it possible to unlock the temp flv file with ur code

Posted by Sonia Sardana Jul 29, 2009

hi,

i downloaded above zip files. but it does not run because of many errors.

please help me

Posted by Selvaraj May 11, 2009
Nevron Diagram
Become a Sponsor
PREMIUM SPONSORS
  • ceTE software specializes in components for dynamic PDF generation and manipulation. The DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and new content to existing PDF documents from within your applications.
    Get 2 Months Free of ASP.NET Hosting for Only $4.95/month! Receive FREE MS SQL and MySQL Databases Including ASP.NET 4/3.5, MVC 3.0, Silverlight 4, Windows 2008/IIS 7.0 Plus FREE IIS 7 Modules. Host UNLIMITED ASP.NET Web Sites - Click Here!
6 Months Free & No Setup Fees ASP.NET Hosting!
Become a Sponsor