views:

37

answers:

2

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?

+1  A: 

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

derek
A: 

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
ho1