VB.Net/File Directory/Path — различия между версиями

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

Текущая версия на 12:45, 26 мая 2010

Get Invalid Path Chars

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


Get Path or File information: extenstion, full path, path root

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 Alternate Directory Separator

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


Path Separator and Volume Separator Char

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