zoukankan      html  css  js  c++  java
  • 示范NTFS 卷上的流

    ' CreateStream.vbs
    ' 示范 NTFS 卷上的流
    ' --------------------------------------------------------
    Option Explicit
    ' 一些常量
    Const L_NotNTFS = "Sorry, the current volume is not NTFS."
    Const L_EnterFile = "Enter a file name"
    Const L_TestNTFS = "Test NTFS"
    Const L_StdFile = "c:\testntfs\test.txt"
    Const L_EnterStream = "Enter a stream name"
    Const L_StdStream = "VersionInfo"
    Const L_EnterTextStream = "Enter the text of the stream"
    Const L_StdContent = "1.0"
    ' 确保当前的卷是 NTFS
    if Not IsNTFS() then
    MsgBox L_NotNTFS
    WScript.Quit
    end if
    ' 查询文件名
    dim sFileName
    sFileName = InputBox(L_EnterFile, L_TestNTFS, L_StdFile)
    if sFileName = "" then WScript.Quit
    ' 查询写入的流
    dim sStreamName
    sStreamName = InputBox (L_EnterStream, L_TestNTFS, L_StdStream)
    if sStreamName = "" then WScript.Quit
    ' 初始化 FS 对象模式
    dim fso, bExist
    set fso = CreateObject("Scripting.FileSystemObject")
    ' 如果文件不存在,则创建它
    dim ts
    if Not fso.FileExists(sFileName) then
    set ts = fso.CreateTextFile(sFileName)
    ts.Close
    end if
    ' 尝试读取流的当前内容
    dim sFileStreamName, sStreamText
    sFileStreamName = sFileName & ":" & sStreamName
    if Not fso.FileExists(sFileStreamName) then
    sStreamText = L_StdContent
    else
    set ts = fso.OpenTextFile(sFileStreamName)
    sStreamText = ts.ReadAll()
    ts.Close
    end if
    ' 查询写入的流的内容
    sStreamText = InputBox (L_EnterTextStream, L_TestNTFS, sStreamText)
    if sStreamText = "" then WScript.Quit
    ' 尝试写入流中
    set ts = fso.CreateTextFile(sFileStreamName)
    ts.Write sStreamText
    ' 关闭应用程序
    set ts = Nothing
    set fso = Nothing
    WScript.Quit
    ' ////////////////////////////////////////////////////////
    ' //“帮助程序”函数</PRE>
    ' IsNTFS() — 验证当前的卷是否为 NTFS
    ' --------------------------------------------------------
    function IsNTFS()
    dim fso, drv
    IsNTFS = False
    set fso = CreateObject("Scripting.FileSystemObject")
    set drv = fso.GetDrive(fso.GetDriveName(WScript.ScriptFullName))
    set fso = Nothing
    if drv.FileSystem = "NTFS" then IsNTFS = True
    end function
    
  • 相关阅读:
    VUE-路由配置及跳转方式
    VUE使用axios请求后端数据
    springboot图片/文件上传
    java中return;语句的作用
    使用maven搭建ssm框架环境
    Java和Tomcat安装教程
    安装tomcat出现的问题
    关于 == 和 equals() 的区别
    关于从request对象中获取路径的问题
    栈和队列_leetcode20
  • 原文地址:https://www.cnblogs.com/MaxWoods/p/395283.html
Copyright © 2011-2022 走看看