如何在.NET(based on c#)中调用系统功能

如何在.NET(based on c#)中调用系统功能

.net(based on c#)的功能无比强大,但是在系统文件操作方面还不能让程序员有天马行空的感觉。
于是很自然的想法是:如何用c#让世界上最聪明的人在代码的世界里,畅通无阻。让我们体验飞的感觉。
答案:vbscript:基于系统操作的vbs文件,可以让我们无所不能。(注意:我说的是基于IT Pro的vbs,而不是  基于IE的vbs).
步骤:(1):写好vbs文件,保存到E盘下。      such as:
ParentFolder = "."
set objShell = CreateObject("Shell.Application")
set objFolder = objShell.NameSpace(ParentFolder)

strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_LocalTime")

For Each objItem in colItems
    If objItem.Month < 10 And objItem.Day < 10 Then
        ChildFolderName = "0" & objItem.Year-2000 & "0" & objItem.Month & "0" & objItem.Day & "vbscript"
        objFolder.NewFolder ChildFolderName
        ChildFolder1 = "." & childFolderName

        set objChildShell1 = CreateObject("Shell.Application")
        set objChildFolder1 = objChildShell1.NameSpace(ChildFolder1)
        objChildFolder1.NewFolder "Comparison"
        objChildFolder1.NewFolder "CSV Files"
        objChildFolder1.NewFolder "SUS BVT SP1"
        objChildFolder1.NewFolder "Validation"
    ElseIf objItem.Month < 10 And objItem.Day > 10 Then

        ChildFolderName = "0" & objItem.Year-2000 & "0" & objItem.Month & objItem.Day & "vbscript"
        objFolder.NewFolder ChildFolderName
        ChildFolder2 = "." & childFolderName

        set objChildShell2 = CreateObject("Shell.Application")
        set objChildFolder2 = objChildShell2.NameSpace(ChildFolder1)
        objChildFolder2.NewFolder "Comparison"
        objChildFolder2.NewFolder "CSV Files"
        objChildFolder2.NewFolder "SUS BVT SP1"
        objChildFolder2.NewFolder "Validation"
    ElseIf objItem.Day < 10 And objItem.Month > 10 Then

        ChildFolderName = "0" & objItem.Year-2000 & objItem.Month & "0" & objItem.Day & "vbscript"
        objFolder.NewFolder ChildFolderName
        ChildFolder3 = "." & childFolderName

        set objChildShell3 = CreateObject("Shell.Application")
        set objChildFolder3 = objChildShell3.NameSpace(ChildFolder1)
        objChildFolder3.NewFolder "Comparison"
        objChildFolder3.NewFolder "CSV Files"
        objChildFolder3.NewFolder "SUS BVT SP1"
        objChildFolder3.NewFolder "Validation" 
    Else
        ChildFolderName = "0" & objItem.Year-2000 & objItem.Month & objItem.Day & "vbscript"
        objFolder.NewFolder ChildFolderName
        ChildFolder4 = "." & childFolderName

        set objChildShell4 = CreateObject("Shell.Application")
        set objChildFolder4 = objChildShell4.NameSpace(ChildFolder1)
        objChildFolder4.NewFolder "Comparison"
        objChildFolder4.NewFolder "CSV Files"
        objChildFolder4.NewFolder "SUS BVT SP1"
        objChildFolder4.NewFolder "Validation"  
    End If
Next
      (2):在.net中调用这个文件
    System.Diagnostics.Process.Start("E:\\CreateFolder.vbs");
ok,一切就是这样简单。一切就是这样完美。呵呵!!!
      

转载于:https://www.cnblogs.com/pojianhuadie/archive/2006/05/08/394315.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值