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

ASP
制作我们自己的Ebay(拍卖系统)(3)
制作我们自己的Ebay(拍卖系统)(4)
制作我们自己的Ebay(拍卖系统)(5)
制作我们自己的Ebay(拍卖系统)(6)
制作我们自己的Ebay(拍卖系统)(8)
制作我们自己的Ebay(拍卖系统)(9)
制作我们自己的Ebay(拍卖系统)(7)
作一个可以直接和浏览器进行交互的组件
用ASP+实现一个简单的计算器(适合入门者)
用多种方法制作WEB页面的计数器
asp+的论坛列表程序---代码部分
asp+的论坛列表程序---页面部分
asp+版本简单的留言板的制作(一)
asp+版本简单的留言板的制作(二)
asp+版本简单的留言板的制作(三)
一个功能完善的专栏管理的程序->这是asp.net的第二个应用(一)
一个功能完善的专栏管理的程序->这是asp.net的第二个应用(二)
一个功能完善的专栏管理的程序->这是asp.net的第二个应用(三)
一个功能完善的专栏管理的程序->这是asp.net的第二个应用(四)
一个功能完善的专栏管理的程序->这是asp.net的第二个应用(五)

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


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-03   浏览: 36 ::
收藏到网摘: 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")
%>