【问题标题】:Select file path on the first selection在第一个选择上选择文件路径
【发布时间】:2019-12-12 12:33:39
【问题描述】:

我应该在此代码中进行哪些更改?

当我打开对话框时,我只想选择一次文件,而不是两次选择文件路径。我必须选择文件路径两次才能在带有该代码的文本框中显示它。

Private Sub BttImportY_Click(sender As Object, e As EventArgs) Handles BttImportY.Click
    TxtNumberListScan.Clear()
    ' Call ShowDialog.
    Dim result As DialogResult = OpenFileDialog1.ShowDialog()
    ' Test result.
    If OpenFileDialog1.ShowDialog() = DialogResult.OK Then
        ' Get the file name.
        Dim path As String = OpenFileDialog1.FileName
        ' Read in text.
        Dim text As String = File.ReadAllText(path)
        Dim lineCount = File.ReadAllLines(path).Length
        TxtCheckDraws.Text = TBIntDLX.Text - 1
        TxtNumberListScan.Text = System.IO.File.ReadAllText(path)
        TxtCheckL.Text = lineCount
        TxtCheckList.Text = TxtCheckL.Text - 1
    End If
End Sub

【问题讨论】:

    标签: vb.net openfiledialog


    【解决方案1】:

    只是,删除这一行:

    Dim result As DialogResult = OpenFileDialog1.ShowDialog()
    

    【讨论】:

      猜你喜欢
      • 2020-04-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-11-07
      相关资源
      最近更新 更多