vb.net - 如何让应用程序检查应用程序目录中是否存在 EXE 文件?
问题描述
我希望我的应用程序在应用程序处于“启动画面”形式时检查 EXE 文件(App1.exe、App2.exe、App3.exe 等),我目前有这个用于启动画面的代码。它使用 form1 作为代码
Private Sub Form2_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim splash As Splash_screen = CType(My.Application.SplashScreen, Splash_screen)
Dim Label() As String = {"Starting Up...", "Verifying apps...", "Finalizing"}
For i As Integer = 0 To Label.Length - 1
splash.UpdateProgress(Label(i), CInt((i + 1) / Label.Length * 100))
System.Threading.Thread.Sleep(1500)
Next
End Sub
End Class```
解决方案
取决于你想用它做什么。但这里有一些 LINQ 可以帮助执行搜索
Dim fileList = {"app1.exe", "app2.exe", "app3.exe"}
Dim allFilesExist = fileList.All(Function(f) System.IO.File.Exists(f))
Dim filesWhichExist = fileList.Where(Function(f) System.IO.File.Exists(f))
Dim filesWhichDontExist = fileList.Where(Function(f) Not System.IO.File.Exists(f))
推荐阅读
- c++ - 何时应在 std::unordered_map/std::unordered_set 上使用 std::map/std::set?
- javascript - 自定义 Strapi 字段显示为空
- javascript - 无法将点击事件上的传单标记限制为仅关闭一次
- r - R上的条件计数器
- python-3.x - 如何正确使用天蓝色身份的“ManagedIdentityCredential”的“get_token”
- r - 根据向量列表对数据框进行子集化
- python - 如何将新的键值对添加到字典列表中?
- html - 宽度和高度
- http - 使用已知页面但用户提供的 url 参数打开重定向。可能的?
- lua - 参考动态多维表