zoukankan      html  css  js  c++  java
  • jscript 处理文件

    一、创建文档

      有以下三种方法:

      1、CreateTextFile 方法

       var fso, f1;
       fso = new ActiveXObject("Scripting.FileSystemObject");
       f1 = fso.CreateTextFile("c:\\testfile.txt", true);
     
      2、使用 FileSystemObject 对象的 OpenTextFile 方法,并设置 ForWriting 标志。
     

      var fso, ts;
      var ForWriting= 2;
      fso = new ActiveXObject("Scripting.FileSystemObject");
      ts = fso.OpenTextFile("c:\\test.txt", ForWriting, true);

      3、使用 OpenAsTextStream 方法,并设置 ForWriting 标志。

      var fso, f1, ts;
      var ForWriting = 2;
      fso = new ActiveXObject("Scripting.FileSystemObject");
      fso.CreateTextFile ("c:\\test1.txt");
      f1 = fso.GetFile("c:\\test1.txt");
      ts = f1.OpenAsTextStream(ForWriting, true);

    二、文档添加内容

      1、首先,打开文档

      使用 FileSystemObject 对象的 OpenTextFile 方法或 File 对象的 OpenAsTextStream 方法。

         newTxt = fso.OpenTextFile("c:\\o11.txt", ForWriting, true);

      2、然后,写入数据。

           

        newTxt.WriteLine('hello'); 

      3、最后,关闭文件

        newTxt.Close();

    三、删除文档

        newTxt.Close();

  • 相关阅读:
    删除指定日期的文件
    pytorch加载数据集
    pytorch ResNet
    pytorch GoogLeNet
    pytorch实现VGG
    pytorch训练AlexNet
    序列化.Net对象到JSON
    c#对象序列化 用来保存对象数据
    Wpf设置listview样式
    wpf listview添加自增序号
  • 原文地址:https://www.cnblogs.com/kk073000/p/2826641.html
Copyright © 2011-2022 走看看