|
-
May 7th, 2024, 11:13 AM
#1
Thread Starter
Junior Member
Run an app from a ListBox
I have an app in vb.net that pulls a list of files from a directory and displays them in a ListBox. These files could be .pdf, .mov, .exe or .docx files. When I select a file from the list, I want it to either display the contents of the .pdf and .docx files or run the .exe and .mov files.
The code builds the ListBox properly, but when I select a file, I get the following error message:
{"An error occurred trying to start process 'F:\WoodWorking\Adirondack_chair _woodrequirements.docx' with working directory 'F:\Woodworking\WWDISPLAY\WoodWorkingFiles\bin\Debug\net6.0-windows'. The specified executable is not a valid application for this OS platform."}
I get the same error message regardless of file type.
Attached is the code in its entirety any working assistance would be greatly appreciated.
Imports System.IO
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
End Sub
Private Sub WoodWorking_SelectedIndexChanged(sender As Object, e As
EventArgs) Handles WoodWorking.SelectedIndexChanged
End Sub
Private Sub BtnStart_Click(sender As Object, e As EventArgs) Handles
BtnStart.Click
Dim finfo As New IO.DirectoryInfo("F:\WoodWorking" )
WoodWorking.Items.Clear()
For Each fi In finfo.GetFiles("*.*" )
WoodWorking.Items.Add(Path.GetFileName(fi.FullName))
Next
End Sub
Private Sub WoodWorking_DoubleClick(sender As Object, e As EventArgs) Handles
WoodWorking.DoubleClick
Dim fullPath = Path.Combine("F:\WoodWorking" ,
WoodWorking.SelectedItem.ToString())
System.Diagnostics.Process.Start(fullPath)
End Sub
End Class
Tags for this Thread
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
|