国产一级a片免费看高清,亚洲熟女中文字幕在线视频,黄三级高清在线播放,免费黄色视频在线看

打開APP
userphoto
未登錄

開通VIP,暢享免費電子書等14項超值服

開通VIP
ASP的FSO組件操作詳解說明 - 夜火博客

FSOFileSystemObject Scripting.FileSystemObject 的縮寫,為 IIS 內(nèi)置組件,用于操作磁盤、文件夾或文本文件。FSO 的對象、方法和屬性非常的多,這里用示例的方式列出常用的,注意:《VBScript 語言參考》或《JScript 語言參考》中的:《FileSystemObject 用戶指南》和《Scripting 運行時庫參考》便是微軟給出的 FileSystemObject 完整參考。

FSO 不能操作二進(jìn)制文件,要操作二進(jìn)制文件,使用:ADODB.Stream。

創(chuàng)建文件
dim fso, f
set fso = server.CreateObject("Scripting.FileSystemObject")
set f = fso.CreateTextFile("C:\test.txt", true) '第二個參數(shù)表示目標(biāo)文件存在時是否覆蓋
f.Write("寫入內(nèi)容")
f.WriteLine("寫入內(nèi)容并換行")
f.WriteBlankLines(3) '寫入三個空白行(相當(dāng)于在文本編輯器中按三次回車)
f.Close()
set f = nothing
set fso = nothing

打開并讀文件
dim fso, f
set fso = server.CreateObject("Scripting.FileSystemObject")
set f = fso.OpenTextFile("C:\test.txt", 1, false) '第二個參數(shù) 1 表示只讀打開,第三個參數(shù)表示目標(biāo)文件不存在時是否創(chuàng)建
f.Skip(3) '將當(dāng)前位置向后移三個字符
f.SkipLine() '將當(dāng)前位置移動到下一行的第一個字符,注意:無參數(shù)
response.Write f.Read(3) '從當(dāng)前位置向后讀取三個字符,并將當(dāng)前位置向后移三個字符
response.Write f.ReadLine() '從當(dāng)前位置向后讀取直到遇到換行符(不讀取換行符),并將當(dāng)前位置移動到下一行的第一個字符,注意:無參數(shù)
response.Write f.ReadAll() '從當(dāng)前位置向后讀取,直到文件結(jié)束,并將當(dāng)前位置移動到文件的最后
if f.atEndOfLine then
   response.Write("一行的結(jié)尾!")
end if
if f.atEndOfStream then
    response.Write("文件的結(jié)尾!")
end if
f.Close()
set f = nothing
set fso = nothing

打開并寫文件
dim fso, f
set fso = server.CreateObject("Scripting.FileSystemObject")
set f = fso.OpenTextFile("C:\test.txt", 2, false) '第二個參數(shù) 2 表示重寫,如果是 8 表示追加
f.Write("寫入內(nèi)容")
f.WriteLine("寫入內(nèi)容并換行")
f.WriteBlankLines(3) '寫入三個空白行(相當(dāng)于在文本編輯器中按三次回車)
f.Close()
set f = nothing
set fso = nothing

判斷文件是否存在
dim fso
set fso = server.CreateObject("Scripting.FileSystemObject")
if fso.FileExists("C:\test.txt") then
    response.Write("目標(biāo)文件存在")
else
    response.Write("目標(biāo)文件不存在")
end if
set fso = nothing

移動文件
dim fso
set fso = server.CreateObject("Scripting.FileSystemObject")
call fso.MoveFile("C:\test.txt", "D:\test111.txt") '兩個參數(shù)的文件名部分可以不同
set fso = nothing

復(fù)制文件
dim fso
set fso = server.CreateObject("Scripting.FileSystemObject")
call fso.CopyFile("C:\test.txt", "D:\test111.txt") '兩個參數(shù)的文件名部分可以不同
set fso = nothing

刪除文件
dim fso
set fso = server.CreateObject("Scripting.FileSystemObject")
fso.DeleteFile("C:\test.txt")
set fso = nothing

創(chuàng)建文件夾
dim fso
set fso = server.CreateObject("Scripting.FileSystemObject")
fso.CreateFolder("C:\test") '目標(biāo)文件夾的父文件夾必須存在
set fso = nothing

判斷文件夾是否存在
dim fso
set fso = server.CreateObject("Scripting.FileSystemObject")
if fso.FolderExists("C:\Windows") then
    response.Write("目標(biāo)文件夾存在")
else
    response.Write("目標(biāo)文件夾不存在")
end if
set fso = nothing

刪除文件夾
dim fso
set fso = server.CreateObject("Scripting.FileSystemObject")
fso.DeleteFolder("C:\test") '文件夾不必為空
set fso = nothing

本站僅提供存儲服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點擊舉報。
打開APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
VBA文件及文件夾操作
FSO組件之文件夾操作(ASP)
vb讀取和寫入多行的txt文件
[寄存]VBS對文件文件夾操作的例子
ASP FSO文件操作
ASP實例教程:FileSystemObject對象
更多類似文章 >>
生活服務(wù)
分享 收藏 導(dǎo)長圖 關(guān)注 下載文章
綁定賬號成功
后續(xù)可登錄賬號暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點擊這里聯(lián)系客服!

聯(lián)系客服