MCTS Programming

www.SarafMoghadam.Com

MCTS Programming

www.SarafMoghadam.Com

کار با فایل (Creat, delete , move , Copy , ...)

File.CreateText("mynewfile.txt")

File.Copy("mynewfile.txt", "newfile2.txt")

File.Move("newfile2.txt", "newfile3.txt")

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

Dim fi As New FileInfo("mynewfile.txt")

fi.CreateText()

fi.CopyTo("newfile2.txt")

Dim fi2 As New FileInfo("newfile2.txt")

fi2.MoveTo("newfile3.txt")

دستور Exists برای وجود داشتن فولدر

Imports System.IO

Dim newdir1 As New DirectoryInfo("d:\111")
Dim newdir2 As New DirectoryInfo("d:\222")

'(1)
If Directory.Exists(newdir1.FullName) Then
     MsgBox("Directory1Exists")
Else
     newdir1.Create()
End If

'(2)
If newdir2.Exists Then
     MsgBox("Directory2Exists")
Else
     newdir2.Create()
End If

گرفتن اطلاعات فایل ها

Imports System.IO

Dim dir As New DirectoryInfo("c:\")

For Each files As FileInfo In dir.GetFiles()
     ListBox1.Items.Add(files.Name)
Next

گرفتن اطلاعات درایو ها

Imports System.IO

For Each di As DriveInfo In DriveInfo.GetDrives()
     ListBox1.Items.Add(di.Name)
Next

ادامه مطلب ...