欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

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

 更新時(shí)間:2007年01月03日 00:00:00   作者:  
一,fso.GetFile
提取文件相應(yīng)的 File 對(duì)象

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)建時(shí)間: " & f2.DateCreated & "<br>"
s = s & "最近訪問(wèn)時(shí)間: " & f2.DateLastAccessed & "<br>"
s = s & "最近修改時(shí)間: " & f2.DateLastModified
response.write(s)
%>



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

其它值附錄如下:


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



二,file.move
作用將指定的文件或文件夾從某位置移動(dòng)到另一位置。其實(shí)該方法仍然屬于fso.GetFile后的一個(gè)應(yīng)用。

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>



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

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

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頁(yè)面同在目錄下的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>



當(dāng)然FSO還沒有結(jié)束,比如上傳文件,ASP轉(zhuǎn)HTML等都需要用到FSO。更精彩的依然是在后面。

相關(guān)文章

最新評(píng)論