如何将directoryInfo文件转换为字符串

时间:2010-04-17 03:12:51

标签: vb.net string directoryinfo

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

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

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

2 个答案:

答案 0 :(得分:1)

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

答案 1 :(得分: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