VB.Net by API/System.IO/Path

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

Path.AltDirectorySeparatorChar

  
Imports System.IO
Module Module1
    Sub Main()
        Console.WriteLine("Alternate Directory Separator {0}", Path.AltDirectorySeparatorChar)
    End Sub
End Module


Path.DirectorySeparatorChar

  
Imports System.IO
Module Module1
    Sub Main()
        Console.WriteLine("Directory Separator {0}", Path.DirectorySeparatorChar)
    End Sub
End Module


Path.GetDirectoryName

  
Imports System.IO
Module Module1
    Sub Main()
        Dim P As String = "\"
        Try
            Console.WriteLine("Starting path: {0}", P)
            Console.WriteLine("Directory name: {0}", Path.GetDirectoryName(P))
            Console.WriteLine("Extension: {0}", Path.GetExtension(P))
            Console.WriteLine("Filename: {0}", Path.GetFileName(P))
            Console.WriteLine("Filename without extension: {0}", Path.GetFileNameWithoutExtension(P))
            Console.WriteLine("Full path: {0}", Path.GetFullPath(P))
            Console.WriteLine("Root: {0}", Path.GetPathRoot(P))
        Catch E As Exception
            Console.WriteLine("Error: {0}", E.Message)
        End Try
        Console.WriteLine()
    End Sub
End Module


Path.GetExtension

  
Imports System.IO
Module Module1
    Sub Main()
        Dim P As String = "\"
        Try
            Console.WriteLine("Starting path: {0}", P)
            Console.WriteLine("Directory name: {0}", Path.GetDirectoryName(P))
            Console.WriteLine("Extension: {0}", Path.GetExtension(P))
            Console.WriteLine("Filename: {0}", Path.GetFileName(P))
            Console.WriteLine("Filename without extension: {0}", Path.GetFileNameWithoutExtension(P))
            Console.WriteLine("Full path: {0}", Path.GetFullPath(P))
            Console.WriteLine("Root: {0}", Path.GetPathRoot(P))
        Catch E As Exception
            Console.WriteLine("Error: {0}", E.Message)
        End Try
        Console.WriteLine()
    End Sub
End Module


Path.GetFileName

  
Imports System.IO
Module Module1
    Sub Main()
        Dim P As String = "\"
        Try
            Console.WriteLine("Starting path: {0}", P)
            Console.WriteLine("Directory name: {0}", Path.GetDirectoryName(P))
            Console.WriteLine("Extension: {0}", Path.GetExtension(P))
            Console.WriteLine("Filename: {0}", Path.GetFileName(P))
            Console.WriteLine("Filename without extension: {0}", Path.GetFileNameWithoutExtension(P))
            Console.WriteLine("Full path: {0}", Path.GetFullPath(P))
            Console.WriteLine("Root: {0}", Path.GetPathRoot(P))
        Catch E As Exception
            Console.WriteLine("Error: {0}", E.Message)
        End Try
        Console.WriteLine()
    End Sub
End Module


Path.GetFileNameWithoutExtension

  
Imports System.IO
Module Module1
    Sub Main()
        Dim P As String = "\"
        Try
            Console.WriteLine("Starting path: {0}", P)
            Console.WriteLine("Directory name: {0}", Path.GetDirectoryName(P))
            Console.WriteLine("Extension: {0}", Path.GetExtension(P))
            Console.WriteLine("Filename: {0}", Path.GetFileName(P))
            Console.WriteLine("Filename without extension: {0}", Path.GetFileNameWithoutExtension(P))
            Console.WriteLine("Full path: {0}", Path.GetFullPath(P))
            Console.WriteLine("Root: {0}", Path.GetPathRoot(P))
        Catch E As Exception
            Console.WriteLine("Error: {0}", E.Message)
        End Try
        Console.WriteLine()
    End Sub
End Module


Path.GetFullPath

  
Imports System.IO
Module Module1
    Sub Main()
        Dim P As String = "\"
        Try
            Console.WriteLine("Starting path: {0}", P)
            Console.WriteLine("Directory name: {0}", Path.GetDirectoryName(P))
            Console.WriteLine("Extension: {0}", Path.GetExtension(P))
            Console.WriteLine("Filename: {0}", Path.GetFileName(P))
            Console.WriteLine("Filename without extension: {0}", Path.GetFileNameWithoutExtension(P))
            Console.WriteLine("Full path: {0}", Path.GetFullPath(P))
            Console.WriteLine("Root: {0}", Path.GetPathRoot(P))
        Catch E As Exception
            Console.WriteLine("Error: {0}", E.Message)
        End Try
        Console.WriteLine()
    End Sub
End Module


Path.GetInvalidFileNameChars()

  
Imports System
Imports System.IO
Imports System.Windows.Forms
Public Class MainClass
   Shared Sub Main()
        For Each ch As Char In Path.GetInvalidFileNameChars()
            Console.Write(ch & " ")
        Next ch
   End Sub 
End Class


Path.GetInvalidPathChars

  
Imports System
Imports System.IO
Imports System.Windows.Forms
Public Class MainClass
   Shared Sub Main()
        For Each ch As Char In Path.GetInvalidPathChars()
            Console.Write(ch & " ")
        Next ch
   End Sub 
End Class


Path.GetPathRoot

  
Imports System.IO
Module Module1
    Sub Main()
        Dim P As String = "\"
        Try
            Console.WriteLine("Starting path: {0}", P)
            Console.WriteLine("Directory name: {0}", Path.GetDirectoryName(P))
            Console.WriteLine("Extension: {0}", Path.GetExtension(P))
            Console.WriteLine("Filename: {0}", Path.GetFileName(P))
            Console.WriteLine("Filename without extension: {0}", Path.GetFileNameWithoutExtension(P))
            Console.WriteLine("Full path: {0}", Path.GetFullPath(P))
            Console.WriteLine("Root: {0}", Path.GetPathRoot(P))
        Catch E As Exception
            Console.WriteLine("Error: {0}", E.Message)
        End Try
        Console.WriteLine()
    End Sub
End Module


Path.VolumeSeparatorChar

  
Imports System.IO
Module Module1
    Sub Main()
        Console.WriteLine("Path Separator {0}", Path.PathSeparator)
        Console.WriteLine("Volume Separator {0}", Path.VolumeSeparatorChar)
    End Sub
End Module