Solved

Working with files and folders in VB.Net

Posted on 2007-03-31
2
242 Views
Last Modified: 2013-11-07
Hi Experts,

I'm having a little trouble working with files and folders in VB.Net.  I'm new to .Net and have been using VB6 for the last 2 years.  To perform the operations I would usually need with VB6 is easy.

I would usually do something like this in VB6:

Reference Windows scripting runtime.
Dim Fsys as new FileSystemObject
Dim XFile as File
Dim XFolder as Folder

Set XFolder = FSys.GetFolder("C:\Data\SubFolder1\SubFolder2\")
For Each XFile In XFolder.Files
   XFile would now reference a specific file and would exposed properties and methods i found useful.
Next XFile

How can do a similar sort of thing in .Net?

Thanks
0
Comment
Question by:PantoffelSlippers
  • 2
2 Comments
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 125 total points
ID: 18828233
Hello DigitalNam,

Dim dir_info As New DirectoryInfo(("C:\Data\SubFolder1\SubFolder2\")
    Dim file_infos() As FileInfo
    file_infos = dir_info.GetFiles("*:*")
    For Each file_info As FileInfo In file_infos
       file_info is now what you are looking for.        
    Next file_info


Regards,

angelIII
0
 
LVL 142

Assisted Solution

by:Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3] earned 125 total points
ID: 18828235
some tips for working with files and folders:
http://vb-helper.com/index_files_and_directories.html
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now