首页 > 解决方案 > 如何让应用程序检查应用程序目录中是否存在 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```

标签: vb.netdirectory

解决方案


取决于你想用它做什么。但这里有一些 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))

推荐阅读