Solved

Working with files and folders in VB.Net

Posted on 2007-03-31
2
246 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 143

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 143

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

679 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