-
call prompt
how can call command prompt from vb.
example:
if u run a command "dir" it will give filelist to u. right. like this i have to give this command from my vb appl. the result will be stored in listbox. without using drivelistbox, or director or some else...
bye..
Regards
Rajesh
^ ^
(*)(*)
(((()))
-
Re: call prompt
TextBox1 stores the command eg dir
TextBox2 gives the results
Code:
Imports System.IO
Imports System.Diagnostics
'add this to the button click event
Dim p As Process
p = New Process()
p.StartInfo.FileName = "cmd.exe"
p.StartInfo.UseShellExecute = False
p.StartInfo.RedirectStandardInput = True
p.StartInfo.RedirectStandardOutput = True
p.StartInfo.CreateNoWindow = True
p.Start()
p.StandardInput.WriteLine(TextBox1.Text)
p.StandardInput.WriteLine("Exit")
TextBox2.Text = p.StandardOutput.ReadToEnd()
p.Close()
-
Re: call prompt
Dead Eyes showed hoe to use the CommadLine.
However if all you want is the Files in a Directory you should use the Directory Class:
Code:
string [] files = Directory.GetFiles(textBox1.Text);
foreach (string file in files)
{
listBox1.Items.Add(file);
}
with textbox1 containing the Path to your folder!
Stephan