当前位置: 首页 > 图文教程 > 网络编程 > ASP > 一些源程序 - 获得文件大小和字符串处理

ASP
asp搜索两个以上的词的原理
如何使用花生壳?
asp汉字转换成汉语拼音代码
asp程序实现伪静态的代码
asp处理xml数据的发送、接收类
ASP中使用jmail发送邮件的函数
asp中获取字符串中的时间字符串
ASP按照字数限制自动截取标题内容
asp中将内容生成word文档的函数
用ASP自动清空IE缓存里的内容
asp检测conn.execute是否执行成功的函数
自动获取当前页面URL的ASP函数
ASP采集中获取网页内所需的html代码
asp图片采集并且本地重命名保存的函数
如何使用asp去字符串中的超链接
asp网站通过限制请求防止被采集的函数
asp利用正则去掉字符串中所有html内容
用ASP取出HTML里面的图片地址的函数
fso实现整个文件夹内容的复制到另一个文件夹中
适合所有表的添加、删除、修改的函数

ASP 中的 一些源程序 - 获得文件大小和字符串处理


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-03   浏览: 62 ::
收藏到网摘: n/a

  Formats passed string based on length. Perfect for emails and text files.
---------------------------------------------------------------------------------------
<%
' Company: Sabra Inc
' Author: Dave Hoffenberg
' Date: 10/5/00
' Function: Formats passed string based on length.  Perfect for emails and text files.
' Freeware

Function Padding(Value, Length)
' If the length of the value is less than the variable 'length'
If Len(Value) < Length Then
charcount = Length - len(Value)

for i = 1 to (charcount - 1)

padding = padding & " "

next

mystring = Value & padding
' If the length of the value is greater than the variable 'length'
Elseif len(Value) > Length Then
mystring = Left(Value,Length)

Else
set mystring = Value

End If

Padding = mystring

End Function


Set fso = CreateObject("Scripting.FileSystemObject")
Set MyFile = fso.CreateTextFile(Server.MapPath("test.txt"), True)

MyFile.WriteLine Padding("this is a test", 25) & "end of line."

Set fso = Nothing
Set MyFile = Nothing

response.write "done"
%>

Retrieves file size(K) of any file passed to it.
---------------------------------------------------------------------------

<%
' Company: Sabra Inc
' Author: Dave Hoffenberg
' Function: Retrieves file size(K) of any file name passed to it.
' Freeware

Function ShowFileSize(filespec)
    file = Server.MapPath(filespec)
Set fso = CreateObject("Scripting.FileSystemObject")
If fso.FileExists(file) Then
    Set f = fso.GetFile(file)
intSizeB = f.Size
    intSizeK = Int((intSizeB/1024) + .5)
    If intSizeK = 0 Then intSizeK = 1
     ShowFileSize = intSizeK & "k"
Else
 ShowFileSize = "File Doesn't Exist"
End If
Set fso = Nothing
End Function

response.write ShowFileSize("test.txt")
%>