locked
Getting information about locked files located on MS 2003 Server RRS feed

  • Question

  • I have a problem with an application leaving large temporary files behind on a server that are locked.

    I would like to find these files using VB 2005.  I want to produce a report that simply list these files so I can use sysinternals tools to delete them.

    They are always located in the root folder of logical drives.

    It seems that all I can do is throw an exception when I write anything to scan the servers logical drives.

    Is there anything in VB 2005 that I can use to spot these files and maybe get information on file size, etc.?

    Is there something within Visual Studio I can leverage?

    Thank you for any suggestions.

    Wednesday, June 28, 2006 5:17 PM

Answers

  • What DMAN1 suggests is one of the methods that throws an exception.  I have done extensive searches on the internet and it looks like what I want may not be possible until Vista is released with its transactional file system.

    I was hoping that since I can see these locked files in Explorer there would be a way to get the same information using VB 2005.

    If not VB, perhaps something in C?

    Thursday, June 29, 2006 5:26 PM

All replies

  • Public NotInheritable Class File

    Inherits System.Object

    Member of: System.IO

    Summary:

    Provides static methods for the creation, copying, deletion, moving, and opening of files, and aids in the creation of System.IO.FileStream objects.

     

    And alos you can use :

    Public NotInheritable Class FileInfo

    Inherits System.IO.FileSystemInfo

    Member of: System.IO

    Summary:

    Provides instance methods for the creation, copying, deletion, moving, and opening of files, and aids in the creation of System.IO.FileStream objects. This class cannot be inherited.

    Wednesday, June 28, 2006 5:25 PM
    Moderator
  • Well, that might be your ticket...  I'm not what exception your getting or how your trying to scan (posting the code and the exception would have been a good idea!) but if you try to access a locked file, an excpetion will occur.  By traping that error when you expect it you can determine that this is a locked file.  While intentionally causing and trapping errors is not really a good idea (generating exceptions is a costly operation), it may be your only option for this particular purpose.

     

    Wednesday, June 28, 2006 9:13 PM
    Moderator
  • What DMAN1 suggests is one of the methods that throws an exception.  I have done extensive searches on the internet and it looks like what I want may not be possible until Vista is released with its transactional file system.

    I was hoping that since I can see these locked files in Explorer there would be a way to get the same information using VB 2005.

    If not VB, perhaps something in C?

    Thursday, June 29, 2006 5:26 PM