Important alert: (current site time 7/16/2013 2:29:36 AM EDT)
 

winzip icon

clsFileAnalyzer v2.5

Email
Submitted on: 2/10/2007 11:18:02 AM
By: -=NightWolf=-  
Level: Intermediate
User Rating: By 16 Users
Compatibility: VB 6.0
Views: 17339
author picture
(About the author)
 
     After quite a long time searching for a decent replacement for the FileSystemObject - which did not require the programmer to include a bloated DLL dependency with the application, making use of a tool that, although useful is rather slow and more often than not, does not yield the desired results one intends it to achieve - I decided to create my own file handling class, for no examples online helped me perform the actions I needed. So, after many attempts and having several times recoded the class from scratch, tweaking and optimizing it for a better performance, and adding functions I haven't seen anywhere else, or at least improving on the most common ones, I think this version is good enough to be released. After all the hard work of compiling a class that is both simple yet featuring advanced functions and thoroughly commenting everything, so it is clear and easy to understand, I have decided to release what I originally intended to keep for private use, so that other people may benefit from this and are not forced to 'reinvent the wheel' every time, when it comes to file, folder and drives management. clsFileAnalyzer contains over 50 different functions for file, folder and disk handling, whereas most of them were created by myself, while a few have been heavily modified from other versions I have come accross online. I have tried to review each one carefully, but if you manage to find a bug or think you could make it faster or more reliable, please do not hesitate to contact me. You will find all my software on www.kaotix-crew.net, where many of my other open source applications have been released, so check back if you're interested. I hope you enjoy this class, - NightWolf

 

Windows API/Global Declarations:

Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
'**************************************
'Windows API/Global Declarations for :clsFileAnalyzer v2.5
'**************************************
Quite a few
winzip iconDownload code

Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. Afterdownloading it, you will need a program like Winzip to decompress it.Virus note:All files are scanned once-a-day by Planet Source Code for viruses, but new viruses come out every day, so no prevention program can catch 100% of them. For your own safety, please:
  1. Re-scan downloaded files using your personal virus checker before using it.
  2. NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.
  3. Scan the source code with Minnow's Project Scanner

If you don't have a virus scanner, you can get one at many places on the net including:McAfee.com

 
Terms of Agreement:   
By using this code, you agree to the following terms...   
  1. You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.
  2. You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
  3. You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
  4. You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.


Other 1 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Intermediate category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments

2/10/2007 8:30:48 AMxpert

Excellent replacement for FileSystemObject. Very well comented and coded. 5 globes from me.
Thanks for releasing this code and contributing with the VB community.
Keep on enhancing the class.
Just a little detail: the form files are in the Classes folder
Will check your site.

(If this comment was disrespectful, please report it.)

 
2/10/2007 1:14:49 PMTheBigB

Very good -- 5 balls from me

Just wondering, what would be faster?
-Compiling to dll and add to the project
or
-Compiling in the project
(If this comment was disrespectful, please report it.)

 
2/10/2007 5:34:01 PM-=NightWolf=-

xpert: Thanks for letting me know, I've updated it now, to optimize it a little bit and moved the forms to where they were supposed to be

TheBigB: Compiling directly in the project should be faster
(If this comment was disrespectful, please report it.)

 
2/11/2007 11:45:42 AMRuturaaj

FYI:
1. SetDriveLabel failed on Virtual Drive.

Suggestions:
1. GetFolderContents should have file filter parameter.
2. Function like DeleteFiles in specific folder (with file extension & Recurse) is needed.

... actually there are many suggestions; but then it may create a feel that I'm not appreciating your work! It's not like that at all though! Good work, but most of the File/Folder related functions are direct API clones (Pathxxx API set); don't you feel so? Just give another thought on your work done so far on this class and I'm sure a hard-working person like you will come-up with a better version! Best Luck. (I won't vote on this, I will wait for your next version to come.) Thanks for sharing your hard work with all of us.
(If this comment was disrespectful, please report it.)

 
2/11/2007 1:12:26 PMxpert

GetDriveTypeName should return "CD-ROM/DVD-ROM" because DVD drives are also considered CD-roms (can they be distinguished by code?).
The class should have 3 functions that return the paths of the main system folders: System, Windows and Temp (like the function GetSpecialFolder of FSO).

(If this comment was disrespectful, please report it.)

 
2/12/2007 9:06:59 AMMohammed Sayed

Amazing , 5* from me

Btw : The get file version function is missing ;)
(If this comment was disrespectful, please report it.)

 
2/12/2007 9:55:01 AM-=NightWolf=-

Ruturaaj:

1. I'm not sure whether SetDriveLabel() works on Virtual Drives at all.

2. You can use Search() to return contents recursively that match a given filter.

3. There is a DeleteFolder() function that removes folders recursively, and you can always build an array with Search() of files/folders matching a criteria and looping to remove each one.

Although a few functions are just a simple interface for certain APIs (so is FSO indeed), some of them are not available as APIs at all, and I believe a n Object Oriented approach makes easier the management of files and folders

xpert:

1. DVD And CD Drives alike are of the 'CD-ROM' system type, it is indeed as so.

2. There is a GetSpecialFolder() function included, which can be used to retrieve the path of the Windows, System and Temp folder as well as many other system paths.
(If this comment was disrespectful, please report it.)

 
2/13/2007 8:51:53 PMxpert

I didn't notice your GetSpecialFolder the first time. Now that you mentioned its name I found it. Yes: it does what I asked for and more.
(If this comment was disrespectful, please report it.)

 
2/21/2007 12:40:14 PMEric O''Sullivan

remove the Dir() function on your Exists call. Dir() does not always return the correct value. It's rare for it to happen but happen it does. I've had it break more than one application.
(If this comment was disrespectful, please report it.)

 
3/7/2007 5:09:48 AMCyberFox

Great work man i really enjoyed playing with the class. i will pm you with anything i think can be changed.
(If this comment was disrespectful, please report it.)

 
3/9/2007 11:47:36 AMviolent_ken

I think it's possible to get greatest performances if you use some other APIs.

Possible to add some other procedure/functions (there are some in my classes : http://www.vbfrance.com/codes/CLASSE-GESTION-FICHIERS-DOSSIERS-INFOS-DATES-COPYRIGHT-LIS TING_40646.aspx )
(If this comment was disrespectful, please report it.)

 
3/13/2007 11:42:42 PMShawn J Cox

Great code, this really helped me out a lot man! 5 from me.

To the guy asking if its faster for DLL or just using the class... its faster using it as a class in your project, as your program cuts out the middle man when calling functions. With the speed of computers nowadays I'm sure it doesn't matter a whole lot anyways.
(If this comment was disrespectful, please report it.)

 
3/28/2007 9:28:18 PMPaul Turcksin

Brilliant piece of work! Excellent code, clear and useful code comments. Thanks for sharing. A BIG fiver.
(If this comment was disrespectful, please report it.)

 
3/29/2007 7:12:37 AMOption Explicit

I missed this originally - When I see the phrase "File System Object" my eyes tend to glaze over ;) But this is GREAT. Glad to see it won a well deserved COTM. As Paul says a big fiver and thanks for sharing.
(If this comment was disrespectful, please report it.)

 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.