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

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

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

DriveInfo: AvaiableFreeSpace, DriveFormat, TotalFreeSpace, VolumnLabel

<source lang="vbnet">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</source>

c:\
True
3
c:\
35531018240
NTFS
35531018240

DriveInfo.GetDrives

<source lang="vbnet">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</source>

C:\
D:\

DriveInfo: Name, IsReady, DriveType, RootDirectory

<source lang="vbnet">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</source>

c:\
True
3
c:\
35531018240
NTFS
35531018240

Get current Drive

<source lang="vbnet">Option Strict On Public Module CurDriveFunction

  Public Sub Main()
     Console.WriteLine("The current drive is {0}.", Left(CurDir(), 1))
  End Sub

End Module</source>

The current drive is C.

Get Logical drives

<source lang="vbnet">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</source>

C:\
D:\