2010-04-17 1 views
1

Проблема в том, что я не могу преобразовать в строкукак вы преобразовать 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 является свойство типа строки. Как преобразовать каталог в строку?

ответ

1

DirectoryInfo имеет свойство FullName, которое является каталогом в качестве строки.

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 

 Смежные вопросы

  • Нет связанных вопросов^_^