·您的位置: 首页 » 资源教程 » 编程开发 » ASP » 一些源程序 - 获得文件大小和字符串处理

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

类别: ASP教程  评论数:0 总得分:0
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")
%>
-= 资 源 教 程 =-
文 章 搜 索
关键词:
类型:
范围:
纯粹空间 softpure.com
Copyright © 2006-2008 暖阳制作 版权所有
QQ: 15242663 (拒绝闲聊)  Email: faisun@sina.com
 纯粹空间 - 韩国酷站|酷站欣赏|教程大全|资源下载|免费博客|美女壁纸|设计素材|技术论坛   Valid XHTML 1.0 Transitional
百度搜索 谷歌搜索 Alexa搜索 | 粤ICP备19116064号-1