亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

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

 更新時間:2007年01月03日 00:00:00   作者:  
一,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 & "文件創(chuàng)建時間: " & f2.DateCreated & "<br>"
s = s & "最近訪問時間: " & f2.DateLastAccessed & "<br>"
s = s & "最近修改時間: " & f2.DateLastModified
response.write(s)
%>



其效果正如右鍵某文件,看到的具體屬性信息。
其中Attributes返回的數值“32”表示:(Archive)上次備份后已更改的文件??勺x寫。

其它值附錄如下:


Normal 0 普通文件。 沒有設置任何屬性。
ReadOnly 1 只讀文件。 可讀寫。
Hidden 2 隱藏文件。 可讀寫。
System 4 系統(tǒng)文件。 可讀寫。
Directory 16 文件夾或目錄。 只讀。
Archive 32 上次備份后已更改的文件。 可讀寫。
Alias 1024 鏈接或快捷方式。 只讀。
Compressed 2048 壓縮文件。 只讀。



二,file.move
作用將指定的文件或文件夾從某位置移動到另一位置。其實該方法仍然屬于fso.GetFile后的一個應用。

2,movefile.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)
f2.Move "C:\"
%>
<a href="C:\">查看下有沒有</a>



簡單的剪切粘貼的功能實現(xiàn)。

三,F(xiàn)ile.Copy
同樣屬于fso.GetFile后的一個應用。就只是單純地拷貝文件到某位置。

3,copyfile.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)
f2.Copy "D:\"
%>
<a href="D:\">查看下有沒有</a>



和本ASP頁面同在目錄下的cnbruce.txt文件依然存在。

四,file.Delete
很顯然,就是直接刪除文件了。

4,delfile.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)
f2.move "d:\"
Set f3 = fso.GetFile("d:\cnbruce.txt")
f3.delete
%>
<a href="d:\">查看下是沒有該文件的</a>



當然FSO還沒有結束,比如上傳文件,ASP轉HTML等都需要用到FSO。更精彩的依然是在后面。

相關文章

最新評論