devxlogo

Redirecting DIR Command Output

Redirecting DIR Command Output

Question:
How do I create the VB equivalent of the command below

DIR C: /S /B >MYFILE.LST
I need this routine for a program that keeps track of installedand removed files.

Answer:
Try:

Shell “COMMAND.COM /C DIR C: /S /B > MYFILE.LST”
That should do what you want it to. DIR is not a program…it is part of the command interpreter.Be aware that you can write a routine in straight VB code that will do this without shelling to DOS. Look in help for the Dir Function (I believe it’s called Dir$ in VB3.0).

devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist