Solved

Working with files and folders in VB.Net

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
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…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

743 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

14 Experts available now in Live!

Get 1:1 Help Now