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

首頁 > 編程 > ASP > 正文

FileSystem對象中常用的文件操作函數介紹

2024-05-04 11:04:58
字體:
來源:轉載
供稿:網友

本篇文章主要介紹了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

以上就是FileSystem對象中常用的文件操作函數介紹,希望小編整理的相關知識和資料都對你們有所幫助,更多內容請繼續關注錯新技術頻道網站!

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 北海市| 米易县| 平阳县| 大连市| 大冶市| 若尔盖县| 佛学| 自治县| 乌拉特后旗| 东平县| 永兴县| 乐业县| 牟定县| 自贡市| 新安县| 临沧市| 日土县| 虞城县| 陈巴尔虎旗| 襄樊市| 浏阳市| 西乌| 阿图什市| 乌苏市| 宿迁市| 日喀则市| 安义县| 甘洛县| 嘉义市| 四平市| 巨野县| 石嘴山市| 荣成市| 修文县| 彭州市| 万安县| 时尚| 德兴市| 泸州市| 都兰县| 基隆市|