|
-
Jun 8th, 2008, 08:16 AM
#1
Thread Starter
Junior Member
Browse for file?
I'm really confused with the whole idea, I want it to browse for a file then run it, but the things in toolbox doesnt import anything!
I want textbox1 to have a button next to it saying "Browse" you click that then click the .exe and it pastes the address of it to the textbox1
Any help will be thanked..THANK YOU!
Last edited by johnathonn; Jun 8th, 2008 at 09:07 AM.
-
Jun 8th, 2008, 09:06 AM
#2
Lively Member
Re: Browse for file?
Well, you can check to see if the file is there by doing:
Code:
Public Function FileExists(ByVal FileFullPath As String) As Boolean
Dim f As New IO.FileInfo(FileFullPath)
Return f.Exists
End Function
Public Function FolderExists(ByVal FolderPath As String) As Boolean
Dim f As New IO.DirectoryInfo(FolderPath)
Return f.Exists
End Function
-
Jun 8th, 2008, 09:23 AM
#3
Thread Starter
Junior Member
Re: Browse for file?
thats a nice bit of code, thank you 
Would i need to project properties and set up my settings for that code? How would it first of all work if i can't browse for the file?
Many thanks, John
-
Jun 8th, 2008, 09:26 AM
#4
Lively Member
Re: Browse for file?
Well, if you want to run an exe, use this:
Code:
Shell("c:\windows\notepad.exe")
Or are you trying to make it load a dialog box, so you can pick the file?
Last edited by Deathader; Jun 8th, 2008 at 09:34 AM.
-
Jun 8th, 2008, 09:33 AM
#5
Re: Browse for file?
vb.net Code:
Private Sub btnBrowse_Click( _ ByVal sender As System.Object, _ ByVal e As System.EventArgs _ ) Handles btnBrowse.Click Dim openFileDlg As New OpenFileDialog openFileDlg.CheckFileExists = True If openFileDlg.ShowDialog = Windows.Forms.DialogResult.OK Then TextBox1.Text = openFileDlg.FileName End If openFileDlg.Dispose() End Sub
-
Jun 8th, 2008, 09:35 AM
#6
Re: Browse for file?
 Originally Posted by Deathader
Well, if you want to run an exe, use this:
Code:
Shell("c:\windows\notepad.exe")
Or are you trying to make it load a dialog box, so you can pick the file?
It's better to do it the .NET way.
vb.net Code:
Process.Start("c:\windows\notepad.exe")
-
Jun 8th, 2008, 09:38 AM
#7
Thread Starter
Junior Member
Re: Browse for file?
Thank you very much! Code works perfect! Would be very handy for future need for any other one!
THANKS AGAIN LIFE SAVER!
-
Jun 8th, 2008, 09:39 AM
#8
Thread Starter
Junior Member
Re: Browse for file?
I eventually used this for the loading of the program and it works a treat
Code:
Dim startInfo As System.Diagnostics.ProcessStartInfo
Dim pStart As New System.Diagnostics.Process
startInfo = New System.Diagnostics.ProcessStartInfo(TextBox3.Text)
pStart.StartInfo = startInfo
pStart.Start()
pStart.WaitForExit()
Then it will wait untill it has loaded to carry on the script, works great!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|