欢迎光临爱时尚女性网
 

获得文件大小和字符串处理

2013-1-31 编辑:admin 来源:爱时尚女性网 阅读次数:618
  导读:Formats passed string based on length. Perfect for emails and text files. --------------------------------------------------------------------------------------- ...
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. 燩erfect 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
燬howFileSize = intSizeK & "k"
Else
燬howFileSize = "File Doesn't Exist"
End If
Set fso = Nothing
End Function


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

文章出自:爱时尚女性网www.aspjc.com,尊重版权是美德,转载请保留原地址,感谢合作!

 
 
链接交换请联系:QQ:790646582 首页链接要求百度快照在一周以内,不符合以上要求的各站,我们将定期把友情连接转入内页,谢谢合作。
Copyright @ 2012-2015 爱时尚女性网 保留所有权利吉ICP备14005127号-1 服务QQ:175529508 e-mail:zk8312@163.com
本站部分资源来自网友上传,如果无意之中侵犯了您的版权,请联系本站,本站将在3个工作日内删除。