• 示范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
    
  • 相关阅读:
    201006120100630
    2010080120100901
    20101120至20101220
    201155学习总结
    PublishReport.rss
    windowservice创建及部署
    提示要角色管理工具安装Microsoft .NET Framework 3.5
    部署SSIS包
    ETL及SSIS
    IbatisNet
  • 原文地址:https://www.cnblogs.com/MaxWoods/p/395283.html
Copyright © 2020-2023  润新知