(源码)CAD二次开发—打开当前图纸所在的目录、临时目录

本文介绍了在CAD二次开发中如何获取当前图纸的目录并打开,以及如何打开临时文件目录。通过C#和.NET进行实现,详细阐述了思路和操作步骤。
摘要由CSDN通过智能技术生成
  1. 打开当前目录
    思路:
    通过dwgprefix参数获取到当前图纸的目录,然后调用System.Diagnostics.Process打开。
[CommandMethod(nameof(OpenCurrentPath))]
    public void  OpenCurrentPath()
    {
        string filePath = (string)Env.GetVar("dwgprefix"); ;//当前文件路径
        if (filePath.Length > 0 && Directory.Exists(filePath))
        {
            System.Diagnostics.Process.Start(filePath);
            Env.Editor.WriteMessage("{0}目录已打开", filePath);
        }
        else
        {
            Env.Editor.WriteMessage("{0}目录不存在", filePath);
        }
    }
  1. 打开临时文件目录
    思路:
    通过TEMPPREFIX参数获取到当前图纸的目录,然后调用System.Diagnostics.Process打开。
    [CommandMethod(nameof(OpenTempPath))]
    public void xOpenTempPath()
    {
        string filePath = (string)Env.GetVar("TEMPPREFIX"); ;//临时文件路径
        if (filePath.Length > 0 && Directory.Exists(filePath))
        {
            System.Diagnostics.Process.Start(filePath);
            Env.Editor.WriteMessage("\n临时目录已打开", filePath);
        }
        else
        {
            Env.Editor.WriteMessage("\n临时目录不存在", filePath);
        }
    }
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值