开发者

how do you convert a directoryInfo file to string

开发者 https://www.devze.com 2022-12-27 00:09 出处:网络
Problem is that i cant convert to string Dim path As String = \"..\\..\\..\\Tier1 downloads\\CourseVB\\\"

Problem is that i cant convert to string

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

'the the lesson is an object, and lessonName is the property of type string. How do i convert the directoryInfo to string?


DirectoryInfo has a FullName property which is the path of the directory as a string.


Your comments conflict with your code and your code looks a little bit buggy. I think you want something like:

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
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号