【问题标题】:Counting amount of files chosen计算选择的文件数量
【发布时间】:2013-10-03 09:46:26
【问题描述】:

我正在使用一个函数来选择几个文件:

Module OpenFileMod
Public Function OpenFile() As String()
    'declare a string, this is will contain the filename that we return
    Dim strFileNames As String()
    'declare a new open file dialog
    Dim fileDialogBox As New OpenFileDialog()

    fileDialogBox.Filter = "Excel Files (*.xls)|*.xls"
    fileDialogBox.Multiselect = True

    'this line tells the file dialog box what folder it should start off in first
    'I selected the users my document folder
    fileDialogBox.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Personal)

    'Check to see if the user clicked the open button
    If (fileDialogBox.ShowDialog() = DialogResult.OK) Then
        strFileNames = fileDialogBox.FileNames
    Else
        MsgBox("You did not select a file!")
    End If

    'return the name of the file
    Return strFileNames
End Function
End Module

我想知道用户选择了多少文件。

我该怎么做?

【问题讨论】:

    标签: vb.net openfiledialog


    【解决方案1】:

    fileDialogBox.FileNames 是一个数组,所以你可以简单地检查它的Length 属性

    strFileNames.Length
    

    【讨论】:

      猜你喜欢
      • 2011-07-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-05-06
      • 2018-05-28
      • 1970-01-01
      相关资源
      最近更新 更多