今天在这里写一个简单的用ASP中的FSO生成静态(HTML)的例子,这只是一个最简单的例子,至于要拿来用的话,还要添加很多东西!

听有些朋友说不能生成,如果不能生成的话那就是你的机子没打开FSO权限,现在就在你的运行里面输入regsvr32 scrrun.dll

下面是核心代码:
<%
'定义文件夹名称函数
function foldername()
dim fodername
fodername=year(now())&month(now())&day(now())
response.write fodername
end function
%>
<%
'定义文件名称函数
function filename()
dim files
files=year(now())&month(now())&day(now())&hour(now())&minute(now())&second(now()) & ".htm"
response.write files
end function
%>

<%
function createfolder()
dim fso,folderpath
if foldername<>"" then
folderpath=server.mappath(".") & folderpath & "\" & foldername
set fso=server.createobject("scripting.filesystemobject")
if not fso.folderExists(folderpath) then
fso.createfolder(folderpath)
echo "文件夹建立成功"
else
echo "<script>alert('有相同命称的文件夹,请重新命名');history.back();</script>"
end if
end if
end function
'上面这个函数是建立文件夹的,注意在这里文件夹只能用数字或英文大小写命名,不可用汉字或别的字符
%>
<%
function createfilename()
dim fso,filepath,filetitle,filecont,fsofile
filecont=request.form("filecont")
filepath=server.mappath(".") & filepath & "\" & filename
set fso=server.createobject("scripting.filesystemobject")
if not fso.fileExists(filepath) then
set fsofile=fso.createtextfile(filepath)
      fsofile=fso.writeline(filecont)
      fsofile.close
      set fsofile=nothing
response.write "文件建立成功"
else
response.write "<script>alert('已经有同名文件');history.back();</script>"
end if
end function
%>

好了,这么一个简单的生成fso就完成了,虽然简单,但刚开始搞的时候头脑就是转不过圈来!今天有空写一下,也希望新手看了之后能解决一下自己的问题。