zoukankan      html  css  js  c++  java
  • VBS 读写文件

    Const fileName = "D:autoSaveParam.txt"
    
    Const Forreading=1
    Const ForWriting=2
    Const Forappending=8
    Dim hP100,hP103,hP105
    Dim  Fso ,tf
    
    'the file exists or not
    Set Fso = CreateObject("Scripting.FileSystemObject")
    If Fso.fileexists(fileName)Then
           'read from file
           Set tf =Fso.opentextfile(fileName,Forreading)
           Do While tf.atendofstream<>True 
                strLine =   tf.ReadLine        
           Loop 
    
    Else 'file not exist
           'create a file and save P paramters into the file
           Set tf=  fso.OpenTextFile(fileName, ForWriting, True)
           tf.writeLine "P105 = 105"
              
    End If 
    tf.close 
    Set Fso =  Nothing

    其中,创建一个新的文件,并向文件写入文本也可以用以下方式:

     'create file and write 
      Dim fso,tf
      Set fso =  CreateObject("Scripting.FileSystemObject")
      Set tf = fso.CreateTextFile(strFileName, True) 'True-代表可以被下次写入覆盖
    
      tf.WriteLine("AABBCC")
      tf.close

    参考:https://blog.csdn.net/hc19881010/article/details/5963818?locationNum=15&fps=1

              https://www.docin.com/p-1613338.html

  • 相关阅读:
    批量给对象属性赋值
    判断linq语句结果是否为空的方法
    linq var出来的object取值问题
    LinQ转换运算符OfType<T>
    C#退出的几种方式
    return的用法
    扩展文字
    Timer的使用方法
    通过16道练习学习Linq和Lambda
    VS2010 无可用源
  • 原文地址:https://www.cnblogs.com/small-lazybee/p/13729947.html
Copyright © 2011-2022 走看看