Which Imports or References needed to dim as Folder and use FileSystemObject?

Roach
03-22-2004, 08:18 PM
I know it is a stupid question but I've been finding confusing results on google: I was looking for a way to declare a variable as a Folder object, so I can set the path and get info about the folder like size, date created, date altered, etc etc. I've been getting my info from http://www.juicystudio.com/tutorial/vb/files.asp#folder but there I am advised to dim an object as New FileSystemObject first, to use GetFolder and thus collect the needed info. It is said on that page that I need to add Microsoft Scripting Runtime Library to my References. I did that, and also imported System.IO, and proceeded to do the necessary dims, but apparently I can not dim as FileSystemObject, only as FileSystemObjectClass. Am I using a VB 6 tutorial for a .NET project? I've used the forum search option, but didn't find any good solutions.

On a side note, I'm using a FolderBrowserDialog so the user can pinpoint the folder he wants to start from (the program should make a nice overview of the total size contained in all the subfolders in this user-given 'root' folder), and have set dlgFolderBrowser.ShowNewFolderButton = False but still the New Folder button is shown when ShowDialog() is called. And yes, I've set it to false BEFORE i called ShowDialog. This is my secondary problem, I'm mainly looking for answers for my main problem described above.

Disclaimer: English is not my first language so if I was unclear at any time, please ask me to rephrase :)

Thanks in advance for helping me.

Roach

Volte
03-22-2004, 08:23 PM
You shouldn't be using the FileSystemObject in .NET (or VB6 for that matter). Instead look at the System.IO namespace in the MSDN. It contains all the functionality you need. That tutorial is a VB6 one, but even if you were using VB6, there are better ways to do what that tutorial accomplishes.

MikeJ
03-22-2004, 08:28 PM
And, if MSDN is too confusing (which it's known to be sometimes), I've posted a File I/O Tutorial for .Net here:
http://www.xtremevbtalk.com/showthread.php?t=148864

Roach
03-23-2004, 05:11 AM
Thanks for the help so far, I am glad to see some confirmation that I was actually using a VB6 tutorial for a .NET project :) And also thanks for the tip, I'll look into the System.IO namespace today and try to accomplish something. Also MikeJ thanks for the tutorial, though there's nothing in it about folders, I'll bookmark it because I'm surely going to need it someday! Thanks :)

Roach
03-23-2004, 07:07 AM
I've just thought of something: With the FileSystemObject, it is possible to request folder size information in one go. Namely folderSpec.Size as seen in the example at http://www.juicystudio.com/tutorial/vb/files.asp#folder . With System.IO, it is stated in the MSDN examples that getting information about the size contained in a folder requires you to iterate through all the files in the folder, and add their sizes. In my opinion, this can take alot of time and consume memory, compared to folderSpec.Size. Is there any way to request the size of a folder in one go (like a .Size property of some sort) with the System.IO method? Any help would be appreciated.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum