VB.Net/File Directory/File System

Материал из VB Эксперт
Перейти к: навигация, поиск

Combine Path

Imports System
Imports System.Windows.Forms
Imports System.IO
Public Class MainClass
   Shared Sub Main()
        Dim file_path As String = My.ruputer.FileSystem.rubinePath(Application.StartupPath, "..\..")
        Console.WriteLine(file_path)
   End Sub 
End Class


File System: Find In Files

Imports System
Imports System.Collections.ObjectModel
Imports System.IO
Public Class MainClass
   Shared Sub Main()
        Dim file_names As ReadOnlyCollection(Of String)
        Dim directory As String = "c:\"
        Dim searchFor As String = "windows"
        
        file_names = My.ruputer.FileSystem.FindInFiles( _
            directory, _
            searchFor, _
            True, _
            FileIO.SearchOption.SearchAllSubDirectories)
        For Each file_name As String In file_names
            Console.WriteLine( file_name )
        Next file_name
   End Sub 
End Class