Solved

Working with files and folders in VB.Net

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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

778 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