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

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

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

FileAttributes

<source lang="vbnet">public class Test

  public Shared Sub Main
       Dim lngAttributes As Long
       lngAttributes = System.IO.File.GetAttributes("test.txt")
       " Use a binary AND to extract the specific attributes.
       Console.WriteLine("Normal: " & CBool(lngAttributes And IO.FileAttributes.Normal))
       Console.WriteLine("Hidden: " & CBool(lngAttributes And IO.FileAttributes.Hidden))
       Console.WriteLine("ReadOnly: " & CBool(lngAttributes And IO.FileAttributes.ReadOnly))
       Console.WriteLine("System: " & CBool(lngAttributes And IO.FileAttributes.System))
       Console.WriteLine("Temporary File: " & CBool(lngAttributes And IO.FileAttributes.Temporary))
       Console.WriteLine("Archive: " & CBool(lngAttributes And IO.FileAttributes.Archive))
  End Sub

End Class</source>

Normal: False
Hidden: False
ReadOnly: False
System: False
Temporary File: False
Archive: True

File"s Attributes

<source lang="vbnet">Option Strict On Imports System.IO Public Module FileSystemAttributes

  Public Sub Main()
     Dim docPath As String = My.ruputer.FileSystem.SpecialDirectories.MyDocuments
     For Each fn As String In My.ruputer.FileSystem.GetFiles(docPath)
        Dim fi As FileInfo = New FileInfo(fn)
        Console.WriteLine("{0}: {1}", fi.Name, fi.Attributes.ToString())
     Next
  End Sub

End Module</source>

Default.rdp: Hidden, Archive
desktop.ini: Hidden, System, Archive