active控件操作本地文件

<!DOCTYPE html> <html> <head> <meta charset="utf-8">  <script>  function Write2Text()  {

  //如果是服务器端就是Server.CreateObject("Scripting.FileSystemObject");   var fso = new ActiveXObject("Scripting.FileSystemObject");    var f = fso.CreateTextFile("E://a.txt", true);      f.write("nihao");    f.WriteBlankLines(1);

  f.Close();  }  function getPath()  {   var ForReading=1;   var filePath="E://a.txt";   if(filePath=="")   return;   var fso = new ActiveXObject("Scripting.FileSystemObject");   var textFile= fso.GetFile(filePath);   var ts= fso.OpenTextFile(filePath,ForReading);   var result= ts.ReadAll();   alert(result);  }   </script> </head> <body> <input type="button" value="写入" onClick="Write2Text()"> <input type="button" value="读取" onClick="getPath()"> </body> </html>

你可能感兴趣的:(Active)