Sunday, November 29, 2009

Check if a file is in use

For a project i need a method to check wether a file is open. The way i do it is very simple. I try to open the file with FileStream. See the code below:

#using System.IO

CLASS FileAccessCheck

STATIC METHOD CanOpenFile( cFile AS STRING ) AS LOGIC

    LOCAL lCanOpen        AS LOGIC
    LOCAL oStream        AS FileStream

    TRY                           
        oStream := System.IO.File.Open( cFile, FileMode.Open, FileAccess.Read, FileShare.None )
        oStream:Close()
        lCanOpen := TRUE      
    CATCH e AS System.IO.IOException      
        lCanOpen := FALSE
    END TRY      

    RETURN ( lCanOpen )

END CLASS


Sunday, November 22, 2009

Hello World

Welcome to my very first post on my new vulcan.net blog. On this blog i want to give you tipps and tricks for vulcan.net. I will release weakly new snippets, articles and links to related vulcan.net stuff and other .NET technologies. I hope you enjoy my new blog, when you have suggestions, please let me know.