怎样用ASP利用FSO生成文件,用当前日记时间命名文件名

怎样用ASP利用FSO生成文件,用当前日记时间命名文件名,第1张

分类: 电脑/网络 >> 程序设计 >> 其他编程语言

问题描述:

获取变量diary,在网站目录下生成一个以当前日记、时间命名的tzt文件(注意需要将日记进行格式化,否则不能做文件名),文件内容为变量diary的值。

请问代码怎么写?

我QQ:,看不懂问题的可以加我Q来问,本问题一直追加到最高分!急用

解析:

<%

diary = "aaaaaaaaaa"

responsewrite time()

filename = year(date()) & month(date()) & day(date()) & hour(time()) & minute(time()) & second(time()) & "txt"

set fso = servercreateobject("scriptingfilesystemobject")

thepath=servermappath(filename)

set thefile = fsocreatetextfile(thepath)

thefilewriteline diary

thefileclose

set fso = Nothing

%>

有什么其它得可以QQ:

<%

'以下为修改内容

Const UploadDir="/picture/" '存放文件的目录

Const Up="/picture/" '存放文件的目录

Const MaxPerPage=30 '每页显示数量

const Webpage="时尚网页" '标题

'检查组件是否已经安装

Function IsObjInstalled(strClassString)

IsObjInstalled = False

Err = 0

Dim xTestObj

Set xTestObj = ServerCreateObject(strClassString)

If 0 = Err Then IsObjInstalled = True

Set xTestObj = Nothing

Err = 0

End Function

dim strFileName

dim totalPut,CurrentPage,TotalPages

dim TruePath,fso,theFolder,theFile,whichfile,thisfile,FileCount,TotleSize

strFileName=""

if request("page")<>"" then

currentPage=cint(request("page"))

else

currentPage=1

end if

TruePath=ServerMapPath(UploadDir)

If not IsObjInstalled("ScriptingFileSystemObject") Then

ResponseWrite "<b><font color=red>你的服务器不支持 FSO(ScriptingFileSystemObject)! 不能使用本功能</font></b>"

Else

set fso=CreateObject("ScriptingFileSystemObject")

if fsoFolderExists(TruePath)then

FileCount=0

TotleSize=0

Set theFolder=fsoGetFolder(TruePath)

For Each theFile In theFolderFiles

FileCount=FileCount+1

TotleSize=TotleSize+theFileSize

next

totalPut=FileCount

if currentpage<1 then

currentpage=1

end if

if (currentpage-1)MaxPerPage>totalput then

if (totalPut mod MaxPerPage)=0 then

currentpage= totalPut \ MaxPerPage

else

currentpage= totalPut \ MaxPerPage + 1

end if

end if

if currentPage=1 then

showContent

showpage2 strFileName,totalput,MaxPerPage

responsewrite "<br><div align='center'>本页共显示 <b>" & FileCount-1 & "</b> 个,占用 <b>" & TotleSize\1024 & "</b> K</div>"

else

if (currentPage-1)MaxPerPage<totalPut then

showContent

showpage2 strFileName,totalput,MaxPerPage

responsewrite "<br><div align='center'>本页共显示 <b>" & FileCount-1 & "</b> 个,占用 <b>" & TotleSize\1024 & "</b> K</div>"

else

currentPage=1

showContent

showpage2 strFileName,totalput,MaxPerPage

responsewrite "<br><div align='center'>本页共显示 <b>" & FileCount-1 & "</b> 个,占用 <b>" & TotleSize\1024 & "</b> K</div><br><br>"

end if

end if

else

responsewrite "找不到文件夹!可能是配置有误!"

end if

end if

sub showContent()

dim c

FileCount=1

TotleSize=0

%>

<TABLE cellSpacing=5 cellPadding=5 border=0>

<TBODY>

<TR bgColor=#ffffff>

<% For Each theFile In theFolderFiles

c=c+1

if FileCount>MaxPerPage then

exit for

elseif c>MaxPerPage(CurrentPage-1) then %>

<TD align=middle width="138">

<img src=<%=(UploadDir & theFileName)%> border=0><br>

<%

dim str

str=""&(theFileName)&""

str1=str

str2=str

str=replace(str,"jpg","")

if instr(1,str,"/")>0 then

str=split(str,"/")

str1=str(0)

end if

%><%=str%>

</td>

<% if FileCount mod 5 =0 then%>

</TR>

<TR bgColor=#ffffff>

<%end if%>

<% FileCount=FileCount+1

TotleSize=TotleSize+theFileSize

end if

Next

%>

</tr></TBODY></table>

<%

end sub

sub showpage2(sfilename,totalnumber,maxperpage)

dim n, i,strTemp

if totalnumber mod maxperpage=0 then

n= totalnumber \ maxperpage

else

n= totalnumber \ maxperpage+1

end if

strTemp= "<TABLE cellSpacing=1 cellPadding=1 border=0 align='center'><TR bgColor=#ffffff><form name='showpages' method='Post' action='" & sfilename & "'><td align='center'>"

strTemp=strTemp & "共 <b>" & totalnumber & "</b> 个 "

if CurrentPage<2 then

strTemp=strTemp & "首页 上一页 "

else

strTemp=strTemp & "<a href='" & sfilename & "page=1'>首页</a> "

strTemp=strTemp & "<a href='" & sfilename & "page=" & (CurrentPage-1) & "'>上一页</a> "

end if

if n-currentpage<1 then

strTemp=strTemp & "下一页 尾页"

else

strTemp=strTemp & "<a href='" & sfilename & "page=" & (CurrentPage+1) & "'>下一页</a> "

strTemp=strTemp & "<a href='" & sfilename & "page=" & n & "'>尾页</a>"

end if

strTemp=strTemp & " 页次:<strong><font color=red>" & CurrentPage & "</font>/" & n & "</strong>页 "

strTemp=strTemp & " <b>" & maxperpage & "</b>" & "个/页"

strTemp=strTemp & " 转到:<select name='page' size='1' onchange='javascript:submit()'>"

for i = 1 to n

strTemp=strTemp & "<option value='" & i & "'"

if cint(CurrentPage)=cint(i) then strTemp=strTemp & " selected "

strTemp=strTemp & ">第" & i & "页</option>"

next

strTemp=strTemp & "</select>"

strTemp=strTemp & "</td></form></tr></table>"

responsewrite strTemp

end sub

%>

以上就是关于怎样用ASP利用FSO生成文件,用当前日记时间命名文件名全部的内容,包括:怎样用ASP利用FSO生成文件,用当前日记时间命名文件名、asp获取服务器一目录下的所有图片的文件名、等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/10065653.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-05-04
下一篇2023-05-04

发表评论

登录后才能评论

评论列表(0条)

    保存