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
    
  • 相关阅读:
    工作了四五年,感觉技术上依旧长进不大
    Web 性能优化:Preload与Prefetch的使用及在 Chrome 中的优先级
    Fundebug支持浏览器报警
    JavaScript是如何工作的:引擎,运行时和调用堆栈的概述!
    Vue UI:Vue开发者必不可少的工具
    阿里巴巴TXD前端小报
    深入了解浏览器存储:对比Cookie、LocalStorage、sessionStorage与IndexedDB
    JavaScript字符串转数字的5种方法及其陷阱
    灵活使用 console 让 js 调试更简单
    JavaScript大师必须掌握的12个知识点
  • 原文地址:https://www.cnblogs.com/MaxWoods/p/395283.html
Copyright © 2011-2022 走看看