سورس کد درمورد FSO و کار با آن

Dim fso As New FileSystemObject

Dim str As TextStream

Dim s As String

Dim fil As File

Private Sub Command1_Click()

CommonDialog1.Filter = "text file(*.txt)|*.txt"

CommonDialog1.ShowOpen

Set str = fso.OpenTextFile(CommonDialog1.FileName)

Do While (str.AtEndOfStream <> True)

s = s & str.Read(1)

Loop

str.Close

Text1 = s

End Sub

Private Sub Command2_Click()

CommonDialog1.Filter = "text file(*.txt)|*.txt"

CommonDialog1.ShowSave

Set str = fso.CreateTextFile(CommonDialog1.FileName)

str.Write (Text1)

str.Close

End Sub

Private Sub Command3_Click()

CommonDialog1.Filter = "text file(*.txt)|*.txt"

CommonDialog1.ShowOpen

Set fil = fso.GetFile(CommonDialog1.FileName)

s = s & "size of file" & fil.Size & vbCrLf

s = s & "date create of file" & fil.DateCreated & vbCrLf

s = s & "parent folder of file" & fil.ParentFolder & vbCrLf

s = s & "path of file" & fil.Path & vbCrLf

MsgBox s

End Sub

Private Sub Command4_Click()

CommonDialog2.Filter = "text file(*.txt)|*.txt"

CommonDialog2.ShowSave

CommonDialog1.Filter = "text file(*.txt)|*.txt"

CommonDialog1.ShowOpen

fso.MoveFile CommonDialog1.FileName, CommonDialog2.FileName

End Sub

 

Private Sub Command5_Click()

CommonDialog2.Filter = "text file(*.txt)|*.txt"

CommonDialog2.ShowSave

CommonDialog1.Filter = "text file(*.txt)|*.txt"

CommonDialog1.ShowOpen

fso.CopyFile CommonDialog1.FileName, CommonDialog2.FileName

End Sub

نوشته شده در تاریخ پنجشنبه 19 آذر 1388    | توسط: محمد و مجید َ    |    |
نظرات()