• vs2010宏


    Imports System
    Imports EnvDTE
    Imports EnvDTE80
    Imports EnvDTE90
    Imports EnvDTE90a
    Imports EnvDTE100
    Imports System.Diagnostics
    Imports MyCmn
    Imports System.Linq
    Imports System.IO


    Public Module Module1
    Private ErrMsg As String
    Private SucessMsg As String
    Sub Test()


    End Sub

    Sub CopyFileToPath()
    SucessMsg
    = ""
    ErrMsg
    = ""

    Dim strDesc As String
    Dim strFileName As String
    Dim strSrc As String
    Dim solutionPathArray
    = DTE.Solution.FullName.Split("\")
    Dim path = ""
    Dim process As System.Diagnostics.Process

    For i
    = 0 To solutionPathArray.Length
    If (i
    = solutionPathArray.Length - 1) Then
    Exit For
    End If
    path
    = path + solutionPathArray(i) + "\"
    Next
    'String.Join("\", solutionPathArray.GetSub(1, solutionPathArray.Count() - 1))
    strSrc = DTE.ActiveDocument.FullName
    strDesc
    = "D:\NewApp_" + Date.Today.ToShortDateString() + "\" + strSrc.Substring(path.Length)
    Try
    Dim di
    = New System.IO.FileInfo(strDesc)
    If System.IO.Directory.Exists(di.DirectoryName)
    = False Then
    System.IO.Directory.CreateDirectory(di.DirectoryName)
    End If

    System.IO.File.Copy(DTE.ActiveDocument.FullName, strDesc, True)

    SucessMsg
    = "Copy成功! [" + strDesc + "]"
    Catch ex As System.Exception
    ErrMsg
    = "Copy失败! 目标:[" + strDesc + "]" + vbLf + vbLf + ex.Message
    process
    = New System.Diagnostics.Process()
    process.StartInfo
    = New System.Diagnostics.ProcessStartInfo("explorer.exe")
    Dim fi
    = New FileInfo(strDesc)
    process.StartInfo.Arguments
    = fi.DirectoryName
    process.Start()

    End Try

    End Sub
    Sub CopyFileToPathWithMsg()
    CopyFileToPath()

    If (String.IsNullOrEmpty(SucessMsg)
    = False) Then
    MsgBox(SucessMsg, MsgBoxStyle.OkOnly Or MsgBoxStyle.Information,
    "成功.")
    End If


    If (String.IsNullOrEmpty(ErrMsg)
    = False) Then
    MsgBox(ErrMsg, MsgBoxStyle.OkOnly Or MsgBoxStyle.Critical,
    "出错!!!")
    End If
    End Sub
    End Module

  • 相关阅读:
    决定你人生高度的,不是你的才能,而是你的态度
    享受六一的最后几分钟
    DB9 公头母头引脚定义及连接
    bzoj3207--Hash+主席树
    bzoj1901 [ Zju2112 ] --树状数组套主席树
    bzoj1723 [ Usaco2009 Feb ] --前缀和(水题)
    bzoj3932 [ CQOI2015 ] --可持久化线段树
    bzoj3037--贪心
    bzoj3388 [ Usaco2004 Dec ] (神奇的解法)
    bzoj2693--莫比乌斯反演+积性函数线性筛
  • 原文地址:https://www.cnblogs.com/shikyoh/p/2128779.html
Copyright © 2020-2023  润新知