Visual Basic NET ( 3)

       

, , ,


VB , Windows, : , , . File System.IO. Directory System.IO.

c: temp 222, 333, 666, 999 1.txt 2.txt.

. , StreamWriter, :

Dim As New System.IO.StreamWriter("E:\VB\Filimon.txt")

.

File:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

' 1.txt temp c: 222 temp c:

File.Copy("c:\temp\1.txt", "c:\temp\222\1.txt")

' 1.txt , 222:

File.Copy("c:\temp\1.txt", "c:\temp\222\1.txt", True)

' 1.txt 3.txt temp c: 222 temp c:

File.Copy("c:\temp\1.txt", "c:\temp\222\3.txt")



' 1.txt 4.txt temp c: :

File.Copy("c:\temp\1.txt", "c:\temp\4.txt", True)

' 1.txt temp c: 333 temp c:

File.Move("c:\temp\1.txt", "c:\temp\333\1.txt")

' 3.txt 5.txt 222 temp c: temp c:

File.Move("c:\temp\222\3.txt", "c:\temp\5.txt")

' 4.txt temp c: 6.txt:

File.Move("c:\temp\4.txt", "c:\temp\6.txt")


' 5.txt temp c:

File.Delete("c:\temp\5.txt")

' 6.txt temp c:, .....

If File.Exists("c:\temp\6.txt") Then Debug.WriteLine(" ") _

Else Debug.WriteLine(" ")

End Sub

.

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

' 6.txt temp c: (Hidden):

File.SetAttributes("c:\temp\6.txt", FileAttributes.Hidden)

' 6.txt temp c:

Debug.WriteLine(File.GetAttributes("c:\temp\6.txt"))

' 6.txt temp c:

Debug.WriteLine(File.GetCreationTime("c:\temp\6.txt"))

' 6.txt temp c:

Debug.WriteLine(File.GetLastAccessTime("c:\temp\6.txt"))

' 6.txt temp c:

File.SetLastWriteTime("c:\temp\6.txt", #11/21/2004 10:42:00 PM#)

' 6.txt temp c:

Debug.WriteLine(File.GetLastWriteTime("c:\temp\6.txt"))

End Sub

: SetAttributes

(, ), GetAttributes .

. Directory:

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click

' temp c: 444:

Directory.CreateDirectory("c:\temp\444")

' temp c: 444, :

Directory.Delete("c:\temp\444")



' 222 temp c:, .....

If Directory.Exists("c:\temp\222") Then Debug.WriteLine(" ") _

Else Debug.WriteLine(" ")

' 666 temp c: 222 temp c:

Directory.Move("c:\temp\666", "c:\temp\222\666")

' 666 777 222 temp c: temp c:

Directory.Move("c:\temp\222\666", "c:\temp\777")

' 777 555:

Directory.Move("c:\temp\777", "c:\temp\555")

End Sub

: Move . . , , .

.

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click

' 333 temp c:

Directory.SetLastAccessTime("c:\temp\333", #3/28/2003 10:22:00 AM#)

' 333 temp c:

Debug.WriteLine(Directory.GetLastAccessTime("c:\temp\333"))

' 333:

Debug.WriteLine(Directory.GetCreationTime("c:\temp\333"))

' 333 temp c:

Debug.WriteLine(Directory.GetLastWriteTime("c:\temp"))

', 333:

Debug.WriteLine(Directory.GetParent("c:\temp\333"))

End Sub



.

Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click



' ( ):

Debug.WriteLine(Directory.GetCurrentDirectory)

' 999 temp c:

Environment.CurrentDirectory

= "c:\temp\999"

' 999:

File.Copy("44.txt", "55.txt")

End Sub

: . . . , , : .

CurrentDirectory Environment System.

, , BIN .

:

', temp c:

Dim () As String = Directory.GetDirectories("c:\temp")

Dim As String

For Each In

Debug.WriteLine()

Next

', temp c:

Dim () As String = Directory.GetFiles("c:\temp")

Dim As String

For Each In

Debug.WriteLine()

Next

', :

Dim () As String = Directory.GetLogicalDrives

Dim As String

For Each In

Debug.WriteLine()

Next

: , , . GetDirectories , GetFiles , GetLogicalDrives . , For Each.