zoukankan      html  css  js  c++  java
  • 在 VS 中,应用宏来定义自定义代码Copy

        Private ErrMsg As String
        Private SucessMsg As String
        'Udi 2012年9月20日
        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.ToString("yyyy-MM-dd") + "\" + 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
    
        'Udi 2012年9月20日
        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

    定义快捷键:

    工具-》选项-》键盘

    列表项,实在太多了,而且变态的MS只给了一个小小的框 。 还好,VS2010提供了搜索:

    在《显示命令包含》中输入 Macros , 即可找到所有的宏。

    补充最重要的一点,文件名要以Module 名一致,即也要是: UdiModule

    alarm   作者:NewSea     出处:http://newsea.cnblogs.com/    QQ,MSN:iamnewsea@hotmail.com

      如无特别标记说明,均为NewSea原创,版权私有,翻载必纠。欢迎交流,转载,但要在页面明显位置给出原文连接。谢谢。
  • 相关阅读:
    以后面试官再问你三次握手和四次挥手,直接把这一篇文章丢给他
    聊聊面试中常问的GC机制
    四面快手、终拿Offer,想告诉你的一些事情
    深入浅出14个Java并发容器
    Dubbo 在 K8s 下的思考
    一文带你深入浅出Spring 事务原理
    如何高效选择一款消息队列?
    当面试官要你介绍一下MQ时,该怎么回答?
    淘宝双11促销背后采用什么架构技术来实现网站的负载均衡
    Android 更改按钮样式 Button Styles
  • 原文地址:https://www.cnblogs.com/newsea/p/2123260.html
Copyright © 2011-2022 走看看