.net - Visual basic 2010 检查表单加载时文件是否存在

标签 .net vb.net visual-studio-2010 if-statement

我希望我的 Visual Basic 应用程序运行一个带有进度条的闪屏,然后检查文件是否存在,但我遇到了一个问题,因为一旦我启动并且闪屏出现,文件检查器就会启动,但我希望它检查何时加载 form1 而不是启动画面。这是我的代码,我可以使用一个建议:

启动画面:

Public NotInheritable Class SplashScreen1

    'TODO: This form can easily be set as the splash screen for the application by going to the "Application" tab
    '  of the Project Designer ("Properties" under the "Project" menu).       

    Private Sub Splashscreen1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Dim Dte As DateTime = DateTime.Now
        Label2.Text = FormatDateTime(Dte, DateFormat.LongDate)

        Timer1.Start()
        Timer2.Start()

    End Sub

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        If ProgressBar1.Value = ProgressBar1.Maximum Then
            Form1.Show()
            Me.Close()
        End If

    End Sub

    Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
        ProgressBar1.PerformStep()
    End Sub
End Class

表格 1:

Imports System.Net
Imports System.IO
Public Class Form1
    Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        If My.Computer.FileSystem.FileExists(Application.StartupPath & "/read me.txt") Then
            MsgBox("file found")
        Else
            MsgBox("not found")
        End If

    End Sub
End Class

最佳答案

尝试将您的 Form1 代码从 Load 事件移动到 Shown 事件。在表单对用户可见之前运行加载,根据我的理解,这不是您想要的。

关于.net - Visual basic 2010 检查表单加载时文件是否存在,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14200744/

相关文章:

c# - WPF:MVVM - 如果命令为空则禁用按钮

c# - 使窗口成为 Interop.Excel Com 对象的子对象

excel - Worksheet.UsedRange.Rows.Count 返回错误结果

c++ - 创建一个没有复选框的弹出式 CMenu

c# - 如何在我的源代码中找到具有特定类型参数的通用调用?

c# - VS Entity Framework 中的Oracle实体不更新代码中的主键

c# - 使用 LINQ 合并列中的非分组元素

c# - 编译器可以在变量实际启动之前为变量赋值吗?

vb.net - 主用户界面窗口未更新控件-跨线程操作无效

c# - 从 USB VID/PID 查找可移动磁盘的 Windows 盘符