asp – 青春部落,流年似水 http://www.youthtribe.com 青春是一场远行,总记不起来时的路。 Mon, 25 Aug 2014 07:40:16 +0000 zh-CN hourly 1 https://wordpress.org/?v=6.1.6 asp – 青春部落,流年似水 http://www.youthtribe.com/archives/1319 http://www.youthtribe.com/archives/1319#respond Mon, 25 Aug 2014 07:40:16 +0000 http://www.youthtribe.com/?p=1319 Server.MapPath()

./当前目录
/网站主目录
../上层目录
~/网站虚拟目录
如果当前的网站目录为E:\wwwroot 应用程序虚拟目录为E:\wwwroot\company 浏览的页面路径为E:\wwwroot\company\news\show.asp
在show.asp页面中使用
Server.MapPath(“./”) 返回路径为:E:\wwwroot\company\news
Server.MapPath(“/”) 返回路径为:E:\wwwroot
Server.MapPath(“../”) 返回路径为:E:\wwwroot\company
Server.MapPath(“~/”) 返回路径为:E:\wwwroot\company
server.MapPath(request.ServerVariables(“Path_Info”))
Request.ServerVariables(“Path_Translated”)
上面两种方式返回路径为 D:\wwwroot\company\news\show.asp

]]>
http://www.youthtribe.com/archives/1319/feed 0
asp – 青春部落,流年似水 http://www.youthtribe.com/archives/1309 http://www.youthtribe.com/archives/1309#respond Sat, 23 Aug 2014 09:17:52 +0000 http://www.youthtribe.com/?p=1309 asp这个变态的家伙,有sever.urlencode编码的,却没有对应的一个解码函数。。。网上搜索了一个urldecode解码函数,亲测可用

Function URLDecode(ByVal urlcode)
	Dim start,final,length,char,i,butf8,pass
	Dim leftstr,rightstr,finalstr
	Dim b0,b1,bx,blength,position,u,utf8
	On Error Resume Next
	b0 = Array(192,224,240,248,252,254)
	urlcode = Replace(urlcode,"+"," ")
	pass = 0
	utf8 = -1
	length = Len(urlcode) : start = InStr(urlcode,"%") : final = InStrRev(urlcode,"%")
	If start = 0 Or length < 3 Then URLDecode = urlcode : Exit Function
	leftstr = Left(urlcode,start - 1) : rightstr = Right(urlcode,length - 2 - final)
	For i = start To final
	char = Mid(urlcode,i,1)
	If char = "%" Then
	bx = URLDecode_Hex(Mid(urlcode,i + 1,2))
	If bx > 31 And bx < 128 Then
	i = i + 2
	finalstr = finalstr & ChrW(bx)
	ElseIf bx > 127 Then
	i = i + 2
	If utf8 < 0 Then
	butf8 = 1 : blength = -1 : b1 = bx
	For position = 4 To 0 Step -1
	If b1 >= b0(position) And b1 < b0(position + 1) Then
	blength = position
	Exit For
	End If
	Next
	If blength > -1 Then
	For position = 0 To blength
	b1 = URLDecode_Hex(Mid(urlcode,i + position * 3 + 2,2))
	If b1 < 128 Or b1 > 191 Then butf8 = 0 : Exit For
	Next
	Else
	butf8 = 0
	End If
	If butf8 = 1 And blength = 0 Then butf8 = -2
	If butf8 > -1 And utf8 = -2 Then i = start - 1 : finalstr = "" : pass = 1
	utf8 = butf8
	End If
	If pass = 0 Then
	If utf8 = 1 Then
	b1 = bx : u = 0 : blength = -1
	For position = 4 To 0 Step -1
	If b1 >= b0(position) And b1 < b0(position + 1) Then
	blength = position
	b1 = (b1 xOr b0(position)) * 64 ^ (position + 1)
	Exit For
	End If
	Next
	If blength > -1 Then
	For position = 0 To blength
	bx = URLDecode_Hex(Mid(urlcode,i + 2,2)) : i = i + 3
	If bx < 128 Or bx > 191 Then u = 0 : Exit For
	u = u + (bx And 63) * 64 ^ (blength - position)
	Next
	If u > 0 Then finalstr = finalstr & ChrW(b1 + u)
	End If
	Else
	b1 = bx * &h100 : u = 0
	bx = URLDecode_Hex(Mid(urlcode,i + 2,2))
	If bx > 0 Then
	u = b1 + bx
	i = i + 3
	Else
	If Left(urlcode,1) = "%" Then
	u = b1 + Asc(Mid(urlcode,i + 3,1))
	i = i + 2
	Else
	u = b1 + Asc(Mid(urlcode,i + 1,1))
	i = i + 1
	End If
	End If
	finalstr = finalstr & Chr(u)
	End If
	Else
	pass = 0
	End If
	End If
	Else
	finalstr = finalstr & char
	End If
	Next
	URLDecode = leftstr & finalstr & rightstr
End Function
Function URLDecode_Hex(ByVal h)
	On Error Resume Next
	h = "&h" & Trim(h) : URLDecode_Hex = -1
	If Len(h) <> 4 Then Exit Function
	If isNumeric(h) Then URLDecode_Hex = cInt(h)
End Function


]]>
http://www.youthtribe.com/archives/1309/feed 0
asp – 青春部落,流年似水 http://www.youthtribe.com/archives/1290 http://www.youthtribe.com/archives/1290#respond Tue, 19 Aug 2014 01:30:38 +0000 http://www.youthtribe.com/?p=1290 Function UnicodeToAsciiFile(strFileName) '先打开unicode的文件 set fso = CreateObject("Scripting.FileSystemObject") set unicodefile = fso.opentextfile(server.MapPath(strFileName),1,false,-1)'-1是指用unicode方式打开 Dim strFileText strFileText = unicodefile.ReadAll'读出文本 unicodefile.close set unicodefile = nothing response.write strFileText'输出一下文本 '写成ascii的文件 set fso2 = CreateObject("Scripting.FileSystemObject") 'Set asciifile = fso2.CreateTextFile(server.MapPath("unicode2ascii.txt"), TRUE , false) Set asciifile = fso2.CreateTextFile(server.MapPath(strFileName), TRUE , false) asciifile.write strFileText asciifile.close set unicodefile = nothing End function ]]> http://www.youthtribe.com/archives/1290/feed 0 asp – 青春部落,流年似水 http://www.youthtribe.com/archives/1279 http://www.youthtribe.com/archives/1279#respond Mon, 04 Aug 2014 01:17:01 +0000 http://www.youthtribe.com/?p=1279 <% 'Normal 0 普通文件。没有设置任何属性。 'ReadOnly 1 只读文件。可读写。 'Hidden 2 隐藏文件。可读写。 'System 4 系统文件。可读写。 'Volume 8 磁盘驱动器卷标。只读。 'Directory 16 文件夹或目录。只读。 'Archive 32 上次备份后已更改的文件。可读写。 'Alias 64 链接或快捷方式。只读。 Dim fso,f Set fso = CreateObject("Scripting.FileSystemObject") Set f = fso.GetFile("D:\WebSite\sunge\html\test\test.htm") if f.attributes <> 1 then f.attributes = 1 end if %> ]]> http://www.youthtribe.com/archives/1279/feed 0