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

首頁 > 編程 > ASP > 正文

asp之FSO大全_ASP教程

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

推薦:asp快速分頁代碼
%@ language = vbscript codepage = 936% % option explicit '強制定義變量 dim idcount'記錄總數 dim pages'每頁條數 dim pagec'總頁數 dim page'頁碼 dim pagenc '每頁顯示的分頁頁碼數量=pagenc*2+1 pagenc=2 dim pagenmax '每頁顯示的分頁的最大頁碼 dim pagenmin

  對于一個支持asp和fso的空間來說有了fso一切變得簡單多了

我也是個新手寫了一些代碼供大家學習研究用

首先看支持fso組件嗎

<%
'FSO組件名稱
dim FSObject
FSObject="Scripting.FileSystemObject"

'=========================================================
'◆是否支持組件
'=========================================================
Function IsObjInstalled(strClassString)
On Error Resume Next
IsObjInstalled = False
Err = 0
Dim xTestObj
Set xTestObj = Server.CreateObject(strClassString)
If 0 = Err Then IsObjInstalled = True
Set xTestObj = Nothing
Err = 0
End Function

if IsObjInstalled(FSObject) then
response.write "√"
else
response.write "×"
end if%>
-------------------------------------------------------
<%
'=========================================================
'◆是否支持組件
'=========================================================
Function IsObjInstalled(strClassString)
On Error Resume Next
IsObjInstalled = False
Err = 0
Dim xTestObj
Set xTestObj = Server.CreateObject(strClassString)
If 0 = Err Then IsObjInstalled = True
Set xTestObj = Nothing
Err = 0
End Function
'=========================================================
'fso 操作
'=========================================================
'◆檢查某一目錄是否存在
'=========================================================
Function CheckDir(FolderPath)
folderpath=Server.MapPath(".")&"/"&folderpath
Set fso= CreateObject(FSObject)
If fso.FolderExists(FolderPath) then
CheckDir = True
Else
CheckDir = False
End if
Set fso= nothing
End Function
'=========================================================
'◆ 根據指定名稱生成目錄
'=========================================================
Function MakeNewsDir(foldername)
dim fs0
Set fso= CreateObject(FSObject)
Set fs0= fso.CreateFolder(foldername)
Set fso = nothing
End Function
'=========================================================
'◆ 如果文件夾不存在則建立新文件夾 ◆
'=========================================================
Function checkFolder(folderpath)
If CheckDir(folderpath) = false Then'如果文件夾不存在
MakeNewsDir(folderpath)'就建一個文件夾
end if
end Function
'=========================================================
'◆ 刪除文件夾 ◆
'=========================================================
Function DeleteFoldera(folderpath)
dim path
Set fso = CreateObject(FSObject)
path=request.ServerVariables("APPL_PHYSICAL_PATH")&folderpath
fso.DeleteFolder(path)
Set fso = nothing
end Function
'=========================================================
'◆ 更改文件夾名稱 ◆
'=========================================================
Function moveFolder(foldername,newfoldername)
isfso
Set fso = CreateObject(FSObject)
fso.moveFolder ""&request.ServerVariables("APPL_PHYSICAL_PATH")&"/"&foldername&"" ,""&request.ServerVariables("APPL_PHYSICAL_PATH")&"/"&newfoldername&""
Set fso =nothing
End Function
'=========================================================
'◆ 刪除指定文件 ◆
'=========================================================
Function DeleteFile(file)
Set fso = CreateObject(FSObject)
fso.DeleteFile request.ServerVariables("APPL_PHYSICAL_PATH")&file
Set fso = nothing
End Function
'=========================================================
'◆ 備份指定文件 ◆
'=========================================================
Function CopyFile(oldfile,newfile)
Set fso = CreateObject(FSObject)
On Error Resume Next
Set fso=Server.CreateObject(FSObject)
oldfile=Server.MapPath(oldfile)
if Err.Number>0 Then call alert("原路徑錯誤!","")
newfile=Server.MapPath(newfile)
if Err.Number>0 Then call alert("新路徑錯誤!","")
fso.CopyFile oldfile,newfile'覆蓋原來的文件
if Err.Number>0 Then call alert(Err.Description,"")
Set fso=nothing
End Function
'=========================================================
'◆ 轉移指定文件 ◆
'=========================================================
Function MoveFile(oldfile,newfile)
Set fso = CreateObject(FSObject)
On Error Resume Next
Set fso=Server.CreateObject(FSObject)
oldfile=Server.MapPath(oldfile)
if Err.Number>0 Then call alert("原路徑錯誤!","")
newfile=Server.MapPath(newfile)
if Err.Number>0 Then call alert("新路徑錯誤!","")
'fso.MoveFile oldfile,newfile'不能覆蓋原來的文件
fso.MoveFile "d:/o/data/test.txt","d:/o/databackup/test3.txt"
if Err.Number>0 Then call alert(Err.Description,"")
Set fso=nothing
End Function
'=========================================================
'◆ 讀取文件代碼 ◆
'=========================================================
Function loadfile(file)'讀取文件
dim ftemp
Set fso = CreateObject(FSObject)
Set ftemp=fso.OpenTextFile(Server.MapPath(""&file&""), 1)
loadfile=ftemp.ReadAll
ftemp.Close
fso.close
set fso=nothing
End Function
'=========================================================
'◆ 根據代碼生成文件 ◆
'=========================================================
'========================================
'■file生成文件名
'■code文件的代碼
'========================================
Function savefile(file,code)'保存文件
dim MyFile
Set fso = CreateObject(FSObject)
Set MyFile = fso.CreateTextFile(Server.mapPath(file), True)
MyFile.WriteLine(code)
MyFile.Close
set MyFile=nothing
End Function
'=========================================================
'◆ 壓縮數據庫 ◆
'=========================================================
'========================================
'■dbPath數據文件路徑
'■boolIs97 access97壓縮
'========================================
Function CompactDB(dbPath,boolIs97)
dim strDBPath,fso,Engine
dbPath=server.mappath(dbpath)
strDBPath = left(dbPath,instrrev(DBPath,"/"))
Set fso = CreateObject(FSObject)
If fso.FileExists(dbPath) Then
Set Engine = CreateObject("JRO.JetEngine")
If boolIs97 = "True" Then
dim JET_3X
Engine.CompactDatabase "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & dbpath, _
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strDBPath & "temp.mdb;" _
&"Jet OLEDB:Engine Type=" & JET_3X
Else
Engine.CompactDatabase "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & dbpath, _
"Provider=Microsoft.Jet.OLEDB.4.0;Jet OLEDB:Database password="&dbpw&";Data Source="&strDBPath&"temp.mdb"
End If
fso.CopyFile strDBPath & "temp.mdb",dbpath
fso.DeleteFile(strDBPath&"temp.mdb")
Set fso = nothing
Set Engine = nothing
CompactDB="當前數據庫,已經壓縮成功!"
Else
CompactDB="數據庫名稱或路徑不正確. 請重試!"
End If
End Function
%>

分享:

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 二连浩特市| 天峻县| 秭归县| 施甸县| 东莞市| 枣阳市| 鄂托克旗| 松阳县| 中西区| 平原县| 巢湖市| 应用必备| 南部县| 酉阳| 阜宁县| 惠东县| 宁陕县| 城口县| 买车| 青海省| 闽侯县| 江阴市| 东光县| 邮箱| 盐边县| 水城县| 安新县| 绥阳县| 务川| 阳高县| 隆尧县| 宁陵县| 东莞市| 遂川县| 安乡县| 新郑市| 甘南县| 平山县| 晴隆县| 广平县| 浦东新区|