Function ReadEntireFile(filespec)
   Const ForReading = 1
   Dim fso, theFile, retstring
   Set fso = CreateObject("Scripting.FileSystemObject")
   Set theFile = fso.OpenTextFile(filespec, ForReading, False)
   Do While theFile.AtEndOfLine <> True
      retstring = theFile.Read(1)
   Loop
   theFile.Close
   ReadEntireFile = retstring
End Function

解决方案 »

  1.   

    哈哈,我不喜欢VB,只用Javascript,况且只在客户端用,即可。
      

  2.   

    改成js的
    function ReadEntireFile(filespec)
    {
       var ForReading = 1;
       var fso, theFile, retstring;
       fso = new ActiveXObject("Scripting.FileSystemObject");
       theFile = fso.OpenTextFile(filespec, ForReading, False);
       while(theFile.AtEndOfLine != true)
       {
          retstring = theFile.Read(1);
       }
       theFile.Close;
       ReadEntireFile = retstring;
    }
      

  3.   

    只在客户端用,那恐怕不能用("Scripting.FileSystemObject")吧,不然会有安全警告的.
    <iframe src="abc.txt" ID="iframe1" width=400 height=100></iframe>
    <script>
    function ss(){
      var s=iframe1.window.document.body.innerText;
      var ar=s.match(/\r/g);
      var n= ar ? (ar.length+1) : 1;
      alert("行数:"+n);
    }
    </script>
      

  4.   

    即使要用("Scripting.FileSystemObject")也不能像前面几位星星那样来傻乎乎的循环,那是最糟糕的程序之一了。 如果你要用("Scripting.FileSystemObject")读行数的代码,我再给你。
      

  5.   

    to: cuixiping(无心
    好啊,就要scripting.filesystem读行数的代码。可以给我吗?
    我现在用特殊行控制。