ado.asp

来自「教师评估系统」· ASP 代码 · 共 54 行

ASP
54
字号
<%
function LoadFile(ByVal File) 
Dim objStream 
On Error Resume Next 
Set objStream = Server.CreateObject("ADODB.Stream") 
With objStream 
.Type = 2 
.Mode = 3 
.Open 
.LoadFromFile Server.MapPath(File) 
if Err.Number<>0 Then 
Response.write "<div align='center'>错误:文件"&File&"无法被打开</div>" 
Err.Clear 
Response.end 
end if 
.Charset = "gb2312" 
.Position = 2 
LoadFile = .ReadText 
.Close 
end With 
Set objStream = Nothing 
end function

sub SaveToFile(ByVal strBody,ByVal File) 
Dim objStream 
On Error Resume Next 
Set objStream = Server.CreateObject("ADODB.Stream") 
With objStream 
.Type = 2 
.Open 
.Charset = "gb2312" 
.Position = objStream.Size 
.WriteText = strBody 
.SaveToFile Server.MapPath(File),2 
.Close 
end With 
Set objStream = Nothing 
end sub

function bytes2bstr(vin) 
strreturn = "" 
for i = 1 to lenb(vin) 
thischarcode = ascb(midb(vin,i,1)) 
if thischarcode < &h80 then 
strreturn = strreturn & chr(thischarcode) 
else 
nextcharcode = ascb(midb(vin,i+1,1)) 
strreturn = strreturn & chr(clng(thischarcode) * &h100 + cint(nextcharcode)) 
i = i + 1 
end if 
next 
bytes2bstr = strreturn 
end function
%>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?