打开指定文件夹并选中文件,打开指定文件 .NET实现

来源:互联网 发布:ubuntu 16.04网络配置 编辑:程序博客网 时间:2024/05/29 12:14
private void btnOpenFile_Click(object sender, EventArgs e)
    {
        string _FilePath = this.txtFileFullPath.Text.Trim();
        if (File.Exists(_FilePath))
        {
            //打开指定文件
            System.Diagnostics.Process.Start(_FilePath);
        }
    }
 
    private void button1_Click(object sender, EventArgs e)
    {
        string _FilePath = this.txtFileFullPath.Text.Trim();
        
        //打开指定文件夹选中文件(路径不存在则默认打开并选中我的文档)
        System.Diagnostics.Process.Start("explorer.exe", "/select," + _FilePath);
        
    }

<script type="text/javascript"><!--google_ad_client = "ca-pub-1944176156128447";/* cnblogs 首页横幅 */google_ad_slot = "5419468456";google_ad_width = 728;google_ad_height = 90;//--></script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
原创粉丝点击