Solved

Working with files and folders in VB.Net

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

860 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