<%

'****************************************************
'作  用：按年月生成保存路径
'参  数：str.
'****************************************************
Function tgzcm_Up_Dir()
    Dim dtnow
	dtnow=Now()
	tgzcm_Up_Dir = Year(dtnow) & Right("0" & Month(dtnow), 2) & "/"
End Function

'生成文件
Function MakeHtml(path,str)'如果没有文件夹将自动创建
	GetFold=Split(path,"/")
	For e=0 to Ubound(GetFold)-1
		If fldr="" then
			fldr=GetFold(e)
		Else
			fldr=fldr&"/"&GetFold(e)
		End if
		If IsFolder(fldr)=False then
			CreateFolder fldr
		End if
	Next
	Set fso = Server.CreateObject("Scripting.filesystemobject")  '创建fso对象
	Set fout = fso.CreateTextFile(server.mappath(path))
	fout.Write str
	fout.close
	set fso = nothing
End Function

'删除文件
Function DelHtml(path)
	If IsExists(path)=True Then 
		set fso = server.CreateObject("Scripting.FileSystemObject")
		fso.DeleteFile(server.mappath(path))
		set fso = nothing
	End If
End Function

'检测文件是否存在
Function IsExists(filespec) 
	Dim fso
	Set fso = CreateObject("Scripting.FileSystemObject")
	If (fso.FileExists(server.MapPath(filespec))) Then
	IsExists = True
	Else
	IsExists = False
	End If
	Set fso=nothing
End Function

'检测文件夹是否存在
Function IsFolder(Folder)
    Set fso = CreateObject("Scripting.FileSystemObject")
	If FSO.FolderExists(server.MapPath(Folder)) Then  
	IsFolder = True
	Else
	IsFolder = False
	End If
End Function

'新建文件夹
Function CreateFolder(fldr) 
    on error resume next
	Dim fso, f
	Set fso = CreateObject("Scripting.FileSystemObject")
	Set f = fso.CreateFolder(Server.MapPath(fldr))
	CreateFolder = f.Path
	Set f=nothing
	Set fso=nothing
End Function

'删除文件夹
Function DelFolder(path)
	If IsFolder(path)=True Then
		Set fso = CreateObject("Scripting.FileSystemObject")
		fso.DeleteFolder(server.mappath(path))
		set fso = Nothing
	End If 
End Function

'读取XX文件夹下的所有子文件夹
Function  GetFolders(fldr)
	Set objFS = Server.CreateObject("Scripting.FileSystemObject")
	Set objFolder = objFS.GetFolder(server.MapPath(fldr))
	dirstr=""
	For Each folder In objFolder.SubFolders
		str = folder.name
		dirstr = str & ","&dirstr
		'Response.Write(folder.name)
	Next
	getfolders=dirstr
	Set objFolder = nothing
	Set objFS = nothing
End Function

'读取XX文件夹下的所有文件列表
Function  GetFolderlist(fldr)
	Dim objFSO,objFolder,objFile,FF '声明 objFSO 变量存放对象实例 
	FF = Server.MapPath(fldr) 
	Set objFSO = Server.CreateObject("Scripting.FileSystemObject") 
	If objFSO.FolderExists(ff) Then 
		Set objFolder = objFSO.GetFolder(ff) 
		For Each objFile in objFolder.Files 
		str = objFile.Name
		dirstr = str & ","&dirstr
		Next
	End If 
	GetFolderlist=dirstr
	Set objFolder = Nothing 
	Set objFSO = Nothing
End Function
%>