【FSO】我要看看TextStream的Write方法能写入多少字符

 

晒晒效果

源码

  1. <%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
  2. <%
  3. Option Explicit
  4. With Response
  5. .Expires=-1
  6. .ExpiresAbsolute=NOW-1
  7. .CacheControl="no-cache"
  8. .AddHeader "Pragme","no-cache"
  9. .Buffer=true
  10. End With
  11. Dim action,formvalue,formvalueLen,fso,ts
  12. formvalue=Trim(Request.Form("txtarea"))
  13. formvalueLen=Len(formvalue)
  14. If formvalue<>"" or formvalue<>null Then
  15. Set fso=Server.CreateObject("Scripting.FileSystemObject")
  16. Set ts=fso.CreateTextFile(Server.MapPath(formvalueLen&".txt"),True,True)
  17. ts.Write(formvalue)
  18. ts.Close
  19. Set ts=Nothing
  20. Set fso=Nothing
  21. End If
  22. %>
  23. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  24. <html xmlns="http://www.w3.org/1999/xhtml">
  25. <head>
  26. <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
  27. <title>我要看看TextStream的Write方法能写入多少字符</title>
  28. <script language="javascript" type="text/javascript">
  29. function ShowTextCount(val){
  30. valval=val.replace(/(^/s*)|(/s*$)/g,""); //替换前后空格相当于vbscript Trim()函数
  31. document.getElementById("showtextresult").innerText="您输入的字符数:"+val.length;
  32. }
  33. </script>
  34. <style type="text/css">
  35. #txtarea{width:600px;height:300px;display:block;}
  36. span{color:red;}
  37. </style>
  38. </head>
  39. <body>
  40. <form method="post" action="TextStreamWriteDemo.asp">
  41. <textarea name="txtarea" id="txtarea" onkeyup="ShowTextCount(this.value);"></textarea>
  42. <input type="submit" value="提交"/>
  43. <input type="reset"/>
  44. <span id="showtextresult">写入了<%=formvalueLen%>个字符</span>
  45. </form>
  46. </body>
  47. </html>
生成结果
 
 
TextStream的Write方法能写入文件,据说能写入20亿个字符。仅仅测试到40w个字符,文件就将近800k了。实际中够用了。不过往浏览器textarea拷贝40w字符就快把浏览器搞崩溃了~!
 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值