ASP FSO判断TXT内容大于2000行则删除最后一行
<%ConstForReading=1,ForWriting=2Dimfso,MyFileSetfso=CreateObject("Scripting.FileSyste...
<%
Const ForReading = 1, ForWriting = 2
Dim fso, MyFile
Set fso = CreateObject("Scripting.FileSystemObject")
Set MyFile = fso.OpenTextFile("WhiteIP.txt", ForReading)
j=0
Do While Not MyFile.atEndOfStream
if j<>0 then
abc = abc + MyFile.ReadLine &","
else
edf = MyFile.ReadLine()
end if
j=j+1
loop
MyFile.Close
if j>0 then
Response.Write "领取成功!激活码为" &edf & ",请您存好!"
else
response.write "对不起,已无激活码可领取!"
end if
if j>1 then
abc=Left(abc,Len(abc)-1) '去掉最后一个符号
end if
'写入内容到文本文件中
Set MyFile = fso.OpenTextFile("WhiteIP.txt", ForWriting, True)
StrQ=split(abc,",")
For i=LBound(StrQ) to UBound(StrQ)
MyFile.WriteLine StrQ(i)
next
MyFile.Close
%>
这个是删除第一行没有判断的.略改成判断行数大于2000行则删除最后一行否则什么都不做 展开
Const ForReading = 1, ForWriting = 2
Dim fso, MyFile
Set fso = CreateObject("Scripting.FileSystemObject")
Set MyFile = fso.OpenTextFile("WhiteIP.txt", ForReading)
j=0
Do While Not MyFile.atEndOfStream
if j<>0 then
abc = abc + MyFile.ReadLine &","
else
edf = MyFile.ReadLine()
end if
j=j+1
loop
MyFile.Close
if j>0 then
Response.Write "领取成功!激活码为" &edf & ",请您存好!"
else
response.write "对不起,已无激活码可领取!"
end if
if j>1 then
abc=Left(abc,Len(abc)-1) '去掉最后一个符号
end if
'写入内容到文本文件中
Set MyFile = fso.OpenTextFile("WhiteIP.txt", ForWriting, True)
StrQ=split(abc,",")
For i=LBound(StrQ) to UBound(StrQ)
MyFile.WriteLine StrQ(i)
next
MyFile.Close
%>
这个是删除第一行没有判断的.略改成判断行数大于2000行则删除最后一行否则什么都不做 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询