Some source programs-Get file size and string handling
Source: Internet
Author: User
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 ' 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 ' 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", "B" & "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
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service