ASP編程入門進階(十八):FSO組件之檔案操作(下)

來源:互聯網
上載者:User
一,fso.GetFile
提取檔案相應的 File 對象
1,getfile.asp
<%
whichfile=Server.MapPath("cnbruce.txt")
Set fso = CreateObject("Scripting.FileSystemObject")
Set f1 = fso.CreateTextFile(whichfile,true)
f1.Write ("This is a test.My Name is cnbruce.")
f1.Close
Set f2 = fso.GetFile(whichfile)

s = "檔案名稱:" & f2.name & "<br>"
s = s & "檔案短路徑名:" & f2.shortPath & "<br>"
s = s & "檔案物理地址:" & f2.Path & "<br>"
s = s & "檔案屬性:" & f2.Attributes & "<br>"
s = s & "檔案大小: " & f2.size & "<br>"
s = s & "檔案類型: " & f2.type & "<br>"
s = s & "檔案建立時間: " & f2.DateCreated & "<br>"
s = s & "最近訪問時間: " & f2.DateLastAccessed & "<br>"
s = s & "最近修改時間: " & f2.DateLastModified
response.write(s)
%>

其效果正如右鍵某檔案,看到的具體屬性資訊。
其中Attributes返回的數值“32”表示:(Archive)上次備份後已更改的檔案。可讀寫。
其它值附錄如下:

Normal 0 普通檔案。
  沒有設定任何屬性。
ReadOnly 1 唯讀檔案。
  可讀寫。
Hidden 2 隱藏檔案。
  可讀寫。
System 4 系統檔案。
  可讀寫。
Directory 16 檔案夾或目錄。
  唯讀。
Archive 32 上次備份後已更改的檔案。
 可讀寫。
Alias 1024 連結或捷徑。
  唯讀。
Compressed 2048 壓縮檔。
  唯讀。

二,file.move
作用將指定的檔案或檔案夾從某位置移動到另一位置。其實該方法仍然屬於fso.GetFile後的一個應用。
相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.