小男孩‘自慰网亚洲一区二区,亚洲一级在线播放毛片,亚洲中文字幕av每天更新,黄aⅴ永久免费无码,91成人午夜在线精品,色网站免费在线观看,亚洲欧洲wwwww在线观看

分享

FileSystemObject的file對(duì)象

 悟靜 2009-07-17
FileSystemObject的TextStream物件 - 小瓜瓜 [首頁]
●可由GetFile來取得File物件:
Private Sub Command1_Click()
Open "c:\test.txt" For Output As #1
Print #1, "test"
Close #1

 

Dim FS As Object
Dim F As Object
Set FS = CreateObject("Scripting.FileSystemObject")
Set F = FS.GetFile("c:\test.txt")
End Sub

●File.Attributes屬性:傳回或設(shè)定檔案的屬性,MSDN上的說明表如下

Normal 0 Normal file. No attributes are set.
ReadOnly 1 Read-only file. Attribute is read/write.
Hidden 2 Hidden file. Attribute is read/write.
System 4 System file. Attribute is read/write.
Volume 8 Disk drive volume label. Attribute is read-only.
Directory 16 Folder or directory. Attribute is read-only.
Archive 32 File has changed since last backup. Attribute is read/write.
Alias 1024 Link or shortcut. Attribute is read-only.
Compressed 2048 Compressed file. Attribute is read-only.
Private Sub Command1_Click()
Dim FS As Object
Dim F As Object
Set FS = CreateObject("Scripting.FileSystemObject")
Set F = FS.GetFile("c:\test.txt")
If (F.Attributes And 1) = 1 Then
MsgBox "這是唯讀檔"
Else
MsgBox "這不是唯讀檔"
End If
End Sub

●File.Copy方法:複製檔案

Private Sub Command1_Click()
Dim FS As Object
Dim F As Object
Set FS = CreateObject("Scripting.FileSystemObject")
Set F = FS.GetFile("c:\test.txt")
F.Copy "c:\test.bak"
End Sub

●File.DateCreated屬性:檔案建立日期

Private Sub Command1_Click()
Dim FS As Object
Dim F As Object
Set FS = CreateObject("Scripting.FileSystemObject")
Set F = FS.GetFile("c:\test.txt")
MsgBox "建立日期:" & F.DateCreated
End Sub

●File.DateLastAccessed屬性:檔案最後存取日期

Private Sub Command1_Click()
Dim FS As Object
Dim F As Object
Set FS = CreateObject("Scripting.FileSystemObject")
Set F = FS.GetFile("c:\test.txt")
MsgBox "最後存取日期:" & F.DateLastAccessed
End Sub

●File.DateLastModified屬性:檔案最後修改

Private Sub Command1_Click()
Dim FS As Object
Dim F As Object
Set FS = CreateObject("Scripting.FileSystemObject")
Set F = FS.GetFile("c:\test.txt")
MsgBox "最後修改日期:" & F.DateLastModified
End Sub

●File.Delete方法:刪除檔案

Private Sub Command1_Click()
Dim FS As Object
Dim F As Object
Set FS = CreateObject("Scripting.FileSystemObject")
Set F = FS.GetFile("c:\test.bak")
F.Delete
End Sub

●File.Drive屬性:檔案所在的磁碟位置

Private Sub Command1_Click()
Dim FS As Object
Dim F As Object
Set FS = CreateObject("Scripting.FileSystemObject")
Set F = FS.GetFile("c:\test.txt")
MsgBox "本檔案在" & F.Drive & "磁碟機(jī)"
End Sub

●File.Move方法:移動(dòng)檔案或改檔名

Private Sub Command1_Click()
Dim FS As Object
Dim F As Object
Set FS = CreateObject("Scripting.FileSystemObject")
Set F = FS.GetFile("c:\test.txt")
F.Move "c:\temp\" '最後一個(gè)字元是斜線為移動(dòng)位置
F.Move "c:\temp" '最後一個(gè)字元不是斜線為修改檔名
End Sub

●File.Name屬性:傳回檔名

Private Sub Command1_Click()
Dim FS As Object
Dim F As Object
Set FS = CreateObject("Scripting.FileSystemObject")
Set F = FS.GetFile("c:\test.txt")
MsgBox "本檔案是" & F.Name
End Sub

●File.ParentFolder屬性:取得所在的資料夾

●File.ParentPath屬性:取得完整的路徑

●File.ShortName屬性:取得短檔名

●File.ShortPath屬性:取得短檔名路徑

●File.Size屬性:傳回檔案大小

Private Sub Command1_Click()
Dim FS As Object
Dim F As Object
Set FS = CreateObject("Scripting.FileSystemObject")
Set F = FS.GetFile("c:\test.txt")
MsgBox F.Size & "Byte(s)"
End Sub

●File.Type屬性:傳回檔案類型

    本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請(qǐng)注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊一鍵舉報(bào)。
    轉(zhuǎn)藏 分享 獻(xiàn)花(0

    0條評(píng)論

    發(fā)表

    請(qǐng)遵守用戶 評(píng)論公約

    類似文章 更多