运行 我的 VB 应用程序在不同设备上出现 Win32 异常

Win32 Exception while running my VB application on different devices

晚上好, 请让我在 VB 中做一个打开文件的应用程序。这是我的代码:

Public Class Form1

Private Sub Form1_click(sender As Object, e As EventArgs) Handles MyClass.Click
    Dim myProc As New System.Diagnostics.Process()
    myProc.StartInfo.FileName = "E:\ex.txt" 'The file in a flash drive
    myProc.Start()
    Me.Hide()
End Sub
End Class

问题是该程序对我来说运行良好(我有最新版本的 .NET Framework),但是,当我在另一个办公室尝试它时,它给出了异常 "System.ComponentModel.Win32Exception 0x80004005 : The system cannot find the file specified"。 拜托,我怎样才能让它在另一台设备上工作(x86 或 x64,有或没有最新版本的 .net 框架)? 谢谢。

更新 1: 我添加了异常代码:0x80004005

更新 2: 我只是在我的代码中编辑了路径,因为旧的只是为了解释我的问题,但这似乎是一个非常糟糕的主意,所以,我只是将路径修改为我项目中的真实路径(E:\ex.txt)

驱动器盘符在所有机器上并不总是相同的,尤其是对于可移动存储。
System.IO.DriveInfo.GetDrives可用于获取所有逻辑驱动器的信息并查找文件:

For Each driveInfo In System.IO.DriveInfo.GetDrives ' loop all logical drives on the computer 

    If driveInfo.DriveType = System.IO.DriveType.Removable Then ' optional check if removable storage device 

        Dim fileInfos = driveInfo.RootDirectory.GetFiles("ex.txt") ' search for driveLetter:\ex.txt 

        If fileInfos.Length > 0 Then

            System.Diagnostics.Process.Start(fileInfos(0).FullName) ' start the file 

            Exit For  ' optional to leave the For loop 

        End If
    End If
Next