mainit123
Technical User
- Jan 24, 2005
- 25
Hello-
I am having a great time coding in Visual Basic using Visual Studio 7.0.9955 doing the kinds of things it was meant to do i.e., forms, dialogs, etc. However, it is probably no surprise that now and then while working alot with ASCII flat files, I need to execute a DOS type command (more, type, dir *.txt, copy file1 + file2) in order to accomplish a file based task such as capturing a specific group of filenames to a string or printing out the contents of a file without having to include a separate subroutine. I am aware of the Shell command and also Shellexecute and have tried in vain to create usable versions of these commands within my code to accomplish the above tasks. I can understand the syntax of something like Tools.Shell """c:\Program Files\SomeFile.exe"""
but simply cannot get even a slight variation of that to Build without error. In addition, I am really interested to know how to use a Windows command with an argument such as, "C:\notepad.exe c:\test\myfile.txt " or something simpler such as, "dir c:\test\*.txt". I realize this approach of using DOS based commands may be an archaic and cumbersome way to do file based work but I am not aware in VB how to gather filenames from a specific directory on the hard drive into a string variable. I know VB can do a bunch of stuff but the syntax of the Shell command is tripping me up, even after reviewing all that I could with Online Help, etc.
Thanks for your help with a couple of examples.
I am having a great time coding in Visual Basic using Visual Studio 7.0.9955 doing the kinds of things it was meant to do i.e., forms, dialogs, etc. However, it is probably no surprise that now and then while working alot with ASCII flat files, I need to execute a DOS type command (more, type, dir *.txt, copy file1 + file2) in order to accomplish a file based task such as capturing a specific group of filenames to a string or printing out the contents of a file without having to include a separate subroutine. I am aware of the Shell command and also Shellexecute and have tried in vain to create usable versions of these commands within my code to accomplish the above tasks. I can understand the syntax of something like Tools.Shell """c:\Program Files\SomeFile.exe"""
but simply cannot get even a slight variation of that to Build without error. In addition, I am really interested to know how to use a Windows command with an argument such as, "C:\notepad.exe c:\test\myfile.txt " or something simpler such as, "dir c:\test\*.txt". I realize this approach of using DOS based commands may be an archaic and cumbersome way to do file based work but I am not aware in VB how to gather filenames from a specific directory on the hard drive into a string variable. I know VB can do a bunch of stuff but the syntax of the Shell command is tripping me up, even after reviewing all that I could with Online Help, etc.
Thanks for your help with a couple of examples.