Click here to Skip to main content
15,886,578 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
here is my code for what i am having trouble with. the code to open the FolderBrowserDialog and select a folder works great. however, i am not sure how to put that into a dos command as indicated below.

Any help will be appreciated.

VB
Private Sub btnDirectory_Click(sender As Object, e As EventArgs) Handles btnDirectory.Click
        Dim objFolderDlg As System.Windows.Forms.FolderBrowserDialog
        objFolderDlg = New System.Windows.Forms.FolderBrowserDialog
        objFolderDlg.SelectedPath = "C:\Test"
        If objFolderDlg.ShowDialog() = DialogResult.OK Then
            'this part still does not work, unable to execute all the dos commands.
            Shell("cmd /c CD{objFolderDlg.SelectedPath} dir /B >C:\Users\%USERNAME%\list\Directory_List.txt", vbHide)

            MessageBox.Show(objFolderDlg.SelectedPath)
        End If
    End Sub
Posted
Comments
Sergey Alexandrovich Kryukov 20-Mar-14 10:28am    
There is no such thing as "DOS command".
—SA

There is no such thing as "DOS command". Please see: http://msdn.microsoft.com/en-us/library/system.diagnostics.process.start%28v=vs.110%29.aspx[^].

Probably, this is all you need.

—SA
 
Share this answer
 
You don't have to use shell commands. .NET Framework has namespace System.IO which contains all classes to get informations about files, folders etc.

Start here:
http://msdn.microsoft.com/library/System.IO%28v=vs.110%29.aspx[^]

This will help you to get list of dirs and files for specified path:
http://msdn.microsoft.com/library/system.io.directory%28v=vs.110%29.aspx[^]

This will help you to save informations to file:
http://msdn.microsoft.com/library/system.io.streamwriter%28v=vs.110%29.aspx[^]

And finally, to get user profile directory:
Environment.GetFolderPath(Environment.SpecialFolder.UserProfile)

Hope it helps you :)
 
Share this answer
 
Thanks for all of the info. I will go through them all and see what i can do to solve this problem.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900