<%
dim ObjFso
ObjFso="Scripting.FileSystemObject"

Function AutoCreateFolder(strPath) ' As Boolean
        'On Error Resume Next
	 Dim objfso, folder
	 Set ObjFso = CreateObject("Scripting.FileSystemObject")
	 if strPath="" or isnull(strPath) Or InStr(strPath, ":") < 0 then
	 	AutoCreateFolder=false
		exit function
	 end if
	 strPath	=	replace(strPath,"\","/")
	 strPath	=	replace(strPath,"//","/")
	 ArrPath	=	Split(strPath, "/")
	 UarrPath	=	Ubound(ArrPath)
	 CurPath	=	""
	 For  i= 0 to UarrPath
		' response.write ArrPath(i)&"<br>"
		 
	 	  CurPath=CurPath&ArrPath(i)&"/"
		  CurPath=	replace(CurPath,"//","/")
	 	  fPath=Server.MapPath(CurPath)
		 If not objFSO.FolderExists(fPath) Then
			 Set f = objFSO.CreateFolder(fPath)
			  CreateFolder = f.Path
		 End If
	 Next
	 Set f=nothing
	 Set fso=nothing
	 If Err = 0 Then
			AutoCreateFolder = True
	 Else
			AutoCreateFolder = False
	 End If
End Function 	


Function ReadFromUTF(TempString,CharSet) 'TempString要读取的模板文件路径; Charset是编码
  Dim str
  Set stm = server.CreateObject("adodb.stream")
  stm.Type = 2 'adTypeBinary=1 adTypeText=2
  stm.Mode = 3 'adModeRead=1 adModeWrite=2 adModeReadWrite=3
  stm.Charset = CharSet
  stm.Open
  stm.loadfromfile Server.MapPath(TempString)
  str = stm.readtext
  stm.Close
  Set stm = Nothing
  ReadFromUTF = str
End Function

Function WriteToUTF(content,sFilen)'将替换后的内容写入HTML文档,content为替换后的字符串,filename为生成的文件名
  Set objStream = Server.CreateObject("ADODB.Stream")
    With objStream
    .Open
    .Charset   = "gb2312"' //编码，这里你可以改成任何编码
    .Position  = objStream.Size
    .WriteText = content' //模版+数据 写入内容
    .SaveToFile server.mappath(sFilen),2' //生成文件路径
    .Close
    End With
  Set objStream = Nothing 
End Function
%>
