(разн.) ← Предыдущая | Текущая версия (разн.) | Следующая → (разн.)
DriveInfo: AvaiableFreeSpace, DriveFormat, TotalFreeSpace, VolumnLabel
Imports System.IO
public class Test
public Shared Sub Main
Dim drive_info As New DriveInfo("c:\")
Console.WriteLine(drive_info.Name())
Console.WriteLine(drive_info.IsReady())
Console.WriteLine(drive_info.DriveType())
Console.WriteLine(drive_info.RootDirectory)
If drive_info.IsReady() Then
Console.WriteLine(drive_info.AvailableFreeSpace())
Console.WriteLine(drive_info.DriveFormat())
Console.WriteLine(drive_info.TotalFreeSpace())
Console.WriteLine(drive_info.VolumeLabel())
End If
End Sub
End class
c:\
True
3
c:\
35531018240
NTFS
35531018240
DriveInfo.GetDrives
Imports System.IO
public class Test
public Shared Sub Main
For Each drive_info As DriveInfo In DriveInfo.GetDrives()
Console.WriteLine(drive_info.Name)
Next drive_info
End Sub
End class
C:\
D:\
DriveInfo: Name, IsReady, DriveType, RootDirectory
Imports System.IO
public class Test
public Shared Sub Main
Dim drive_info As New DriveInfo("c:\")
Console.WriteLine(drive_info.Name())
Console.WriteLine(drive_info.IsReady())
Console.WriteLine(drive_info.DriveType())
Console.WriteLine(drive_info.RootDirectory)
If drive_info.IsReady() Then
Console.WriteLine(drive_info.AvailableFreeSpace())
Console.WriteLine(drive_info.DriveFormat())
Console.WriteLine(drive_info.TotalFreeSpace())
Console.WriteLine(drive_info.VolumeLabel())
End If
End Sub
End class
c:\
True
3
c:\
35531018240
NTFS
35531018240
Get current Drive
Option Strict On
Public Module CurDriveFunction
Public Sub Main()
Console.WriteLine("The current drive is {0}.", Left(CurDir(), 1))
End Sub
End Module
The current drive is C.
Get Logical drives
Imports System.IO
Public Class Tester
Public Shared Sub Main
Dim StrS() As String
Dim i As Integer
StrS = System.IO.Directory.GetLogicalDrives()
For i = 0 To StrS.Length - 1
Console.WriteLine(StrS(i))
Next i
End Sub
End Class
C:\
D:\