1

问题是我无法转换为字符串

Dim path As String = "..\..\..\Tier1 downloads\CourseVB\"


If countNumberOfFolders > 0 Then 'if there is a folder then


    ' make a reference to a directory
    Dim di As New IO.DirectoryInfo(path)
    Dim diar1 As IO.DirectoryInfo() = di.GetDirectories()
    Dim dra As IO.DirectoryInfo

    'list the names of all files in the specified directory
    For Each dra In diar1

        Dim lessonDirectoryName() As Lesson
        lessonDirectoryName(0).lessonName = dra

    Next

'课程是一个对象,课程名称是字符串类型的属性。如何将 directoryInfo 转换为字符串?

4

2 回答 2

1

DirectoryInfo 有一个 FullName 属性,它是字符串的目录路径。

于 2010-04-17T04:16:18.217 回答
0

您的评论与您的​​代码冲突,您的代码看起来有点错误。我想你想要这样的东西:

Dim lessonDirectoryNames As New List(Lesson)        
If Directory.Exists(path) Then
    For Each fileName as String In Directory.GetFiles(path)
        Dim les as New Lesson
        les.lessonName = fileName
        lessonDirectoryName.Add(les)
    Next 
End If
于 2010-04-17T09:46:42.727 回答