国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > ASP > 正文

FileSystem對象常用的文件操作函數有哪些?

2024-05-04 11:07:53
字體:
來源:轉載
供稿:網友
FileSystem對象常用的文件操作函數有哪些?
1、root
函數格式 root()
功能描述 返回一個路徑串變量
應用代碼 'sample string = c:/intels/jingcaichunfeng/' 
Public Function root() 
root = Request.ServerVariables("Appl_Physical_Path") 
End Function

2、url
函數格式 url()
功能描述 返回一個URL串變量
應用代碼 'sample string = http://www.intels.net/filesys.asp' 
Public Function url() 
url ="http://"&Request.ServerVariables("Server_Name") 
&Request.ServerVariables("Script_Name") 
End Function 

3、mkdir
函數格式 mkdir( DIrName )
功能描述 創建一個目錄并返回信息
應用代碼 Public Function mkdir( xVar ) 
Set Sys = Server.CreateObject("Scripting.FileSystemObject") 
If Sys.FolderExists( xVar ) Then 
msg ="抱歉,該目錄已存在! " 
Else 
Sys.CreateFolder( xVar ) 
msg ="恭喜,目錄創建成功! " 
End If 
Set Sys = Nothing 
mkdir = msg 
End Function

4、rmdir
函數格式 rmdir( DirName )
功能描述 刪除一個目錄并返回信息
應用代碼 Public Function rmdir( xVar ) 
Set Sys = Server.CreateObject("Scripting.FileSystemObject") 
If Sys.FolderExists( xVar ) Then 
Sys.DeleteFolder( xVar ) 
msg ="恭喜,目錄刪除成功!" 
Else 
msg ="抱歉,該目錄還未被創建! " 
End If 
Set Sys = Nothing 
rmdir = msg 
End Function

5、isdir
函數格式 isdir( DirName )
功能描述 檢查一個目錄是否存在并返回信息
應用代碼 Public Function isdir( xVar ) 
Set Sys = Server.CreateObject("Scripting.FileSystemObject") 
If Sys.FolderExists( xVar ) Then 
msg = True 
Else 
msg = False 
End If 
Set Sys = Nothing 
isdir = msg 
End Function

6、cpdir
函數格式 cpdir( DirName, Destination, OverWrite )
功能描述 復制文件夾并返回信息
應用代碼 Public Function cpdir( xVar, yVar, zVar ) 
Set Sys = Server.CreateObject("Scripting.FileSystemObject") 
If Sys.FolderExists( xVar ) Then 
Sys.CopyFolder xVar, root&yVar, zVar 
msg ="恭喜,目錄復制成功!" 
Else 
msg ="抱歉,沒有找到您想要的目錄!" 
End If 
Set Sys = Nothing 
cpdir = msg 
End Function

7、mvdir
函數格式 mvdir( DirName, Destination )
功能描述 移動一個文件夾并返回信息
應用代碼 Public Function mvdir( xVar, yVar ) 
Set Sys = Server.CreateObject("Scripting.FileSystemObject") 
If Sys.FolderExists( xVar ) Then 
Sys.MoveFolder xVar, root&yVar 
msg ="恭喜,目錄夾已移動!" 
Else 
msg ="抱歉,沒有找到您想要的目錄!" 
End If 
Set Sys = Nothing 
mvdir = msg 
End Function

8、isfile
函數格式 isfile( FileName )
功能描述 檢查文件是否存在并返回信息
應用代碼 Public Function isfile( xVar ) 
Set Sys = Server.CreateObject("Scripting.FileSystemObject") 
If Sys.FileExists( xVar ) Then 
msg = True 
Else 
msg = False 
End If 
Set Sys = Nothing 
isfile = msg 
End Function

9、wfile
函數格式 wfile( FileName, OverWrite, String )
功能描述 寫入串到一個文件并返回信息
應用代碼 Public Function wfile( xVar, yVar, zVar ) 
Set Sys = Server.CreateObject("Scripting.FileSystemObject") 
If yVar Then 
Set Txt = Sys.OpenTextFile( xVar, 2 ) 
Txt.Write( zVar ) 
Txt.Close 
msg ="恭喜,文件創建成功并保存!" 
Else 
If Sys.FileExists( xVar ) Then 
msg ="抱歉,文件已經存在!" 
End If 
Set Sys = Nothing 
wfile = msg 
End Function

10、rfile
函數格式 rfile( FileName )
功能描述 讀取一個文件并返回信息
應用代碼 Public Function rfile( xVar ) 
Set Sys = Server.CreateObject("Scripting.FileSystemObject") 
If Sys.FileExists( xVar ) Then 
Set Txt = Sys.OpenTextFile( xVar, 1 ) 
msg = Txt.ReadAll 
Txt.Close 
Else 
msg ="抱歉,文件不存在!" 
End If 
Set Sys = Nothing 
rfile = msg 
End Function

11、afile
函數格式 afile( FileName, String )
功能描述 添加串到一個文件并返回信息
應用代碼 Public Function afile( xVar, zVar ) 
Set Sys = Server.CreateObject("Scripting.FileSystemObject") 
If Sys.FileExists( xVar ) Then 
Set Txt = Sys.OpenTextFile( xVar, 8 ) 
Txt.Write( zVar ) 
Txt.Close 
msg ="恭喜,文件添加成功并保存!" 
Else 
msg ="抱歉,文件不存在!" 
End If 
Set Sys = Nothing 
afile = msg 
End Function

12、cpfile
函數格式 cpfile( FileName, Destination, OverWrite )
功能描述 復制一個文件并返回信息
應用代碼 Public Function cpfile( xVar, yVar, zVar ) 
Set Sys = Server.CreateObject("Scripting.FileSystemObject") 
If Sys.FileExists( xVar ) Then 
Sys.CopyFile xVar, root&yVar, zVar 
msg ="恭喜,文件復制成功!" 
Else 
msg ="抱歉,文件復制失敗!" 
End If 
Set Sys = Nothing 
cpfile = msg 
End Function

13、mvfile
函數格式 mvfile( FileName, Destination )
功能描述 移動一個文件并返回信息
應用代碼 Public Function mvfile( xVar, yVar ) 
Set Sys = Server.CreateObject("Scripting.FileSystemObject") 
If Sys.FileExists( xVar ) Then 
Sys.MoveFile xVar, root&yVar 
msg ="恭喜,文件移動成功!" 
Else 
msg ="抱歉,文件移動失敗!" 
End If 
Set Sys = Nothing 
mvfile = msg 
End Function

14、rmfile 
函數格式 rmfile( FileName )
功能描述 刪除一個文件并返回信息
應用代碼 Public Function rmfile( xVar ) 
Set Sys = Server.CreateObject("Scripting.FileSystemObject") 
If Sys.FileExists( xVar ) Then 
Sys.DeleteFile( xVar ) 
msg ="恭喜,文件刪除成功!" 
Else 
msg ="抱歉,文件刪除失敗!" 
End If 
Set Sys = Nothing 
rmfile = msg 
End Function
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 湘乡市| 巴中市| 卢龙县| 阳春市| 绥中县| 安阳县| 辰溪县| 秦安县| 黄山市| 讷河市| 开远市| 车致| 云梦县| 昭平县| 襄城县| 云浮市| 宜章县| 西林县| 井陉县| 景泰县| 孟村| 潞西市| 汝南县| 宁武县| 东兰县| 大关县| 铁岭市| 雅安市| 航空| 石林| 巴林左旗| 龙井市| 全椒县| 台中市| 沙坪坝区| 云龙县| 南昌市| 丹巴县| 淳化县| 南宫市| 怀仁县|