当前位置: 移动技术网 > IT编程>开发语言>.net > 一些源程序 - 获得文件大小和字符串处理

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

2019年01月06日  | 移动技术网IT编程  | 我要评论

11个月宝宝发育指标,佳木斯五中校园网,张满泉

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 doesnt exist"
end if
set fso = nothing
end function

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

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网