在好例子网,分享、交流、成长!
您当前所在位置:首页C# 开发实例C#语言基础 → C# 快速打开文件夹(桌面快捷操作工具)

C# 快速打开文件夹(桌面快捷操作工具)

C#语言基础

下载此实例
  • 开发语言:C#
  • 实例大小:0.22M
  • 下载次数:21
  • 浏览次数:457
  • 发布时间:2020-08-20
  • 实例类别:C#语言基础
  • 发 布 人:war3mars
  • 文件格式:.rar
  • 所需积分:6
 相关标签: 桌面 工具 操作

实例介绍

【实例简介】

【实例截图】

from clipboard


from clipboard

【核心代码】

using Microsoft.Win32;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Configuration;
using System.Diagnostics;
using System.Windows.Interop;

namespace 桌面操作工具
{
    /// <summary>
    /// MainWindow.xaml 的交互逻辑
    /// </summary>
    ///  
    /// 
    
    public partial class MainWindow : Window
    {
        Configuration cfa = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
        public MainWindow()
        {

            InitializeComponent();
          
        }

        //private void BTN_Click(object sender, RoutedEventArgs e)
        //{
        //   // OpenFileDialog fileDialog = new OpenFileDialog();
        //   // fileDialog.Multiselect = true;
        //   // fileDialog.OpenFile (TXB.Text.ToString());
        //   //fileDialog.Title = TXB.Text.ToString();
        //   // fileDialog.Filter = "所有文件(*.*)|*.*";
        //   // if (DialogResult.HasValue)
        //   // {

        //   //     fileDialog.ShowDialog();

        //   // }
        //   // else
        //   // {
        //   //     MessageBox.Show("无指定文件");
        //   // }
        //    //打开文件System.Diagnostics.Process.Start(v_OpenFilePath);
        //    //打开指定目录的文件夹string v_OpenFolderPath = @"目录路径"; 
        //    //System.Diagnostics.Process.Start("explorer.exe", v_OpenFolderPath);


           

        ////    string v_OpenFolderPath =@"E:\6.4资料";
        ////    System.Diagnostics.Process.Start("explorer.exe", v_OpenFolderPath);
        //}
        string No1_adress, No2_adress, No3_adress, No4_adress, No5_adress, No6_adress, No7_adress, No8_adress, No9_adress, No10_adress;

        //[System.Runtime.InteropServices.DllImport("User32.dll")]

        //private static extern bool ShowWindowAsync(IntPtr hWnd, int cmdShow);

        //[System.Runtime.InteropServices.DllImport("user32.dll")]

        //private static extern int SetForegroundWindow(IntPtr hWnd);
        private void Window_Load(object sender, RoutedEventArgs e)
        {

            Process[] pro = Process.GetProcesses();
            int n = pro.Where(p => p.ProcessName.Equals("桌面操作工具")).Count();
            if (n > 1)
            {
                //ShowWindowAsync(new System.Windows.Interop.WindowInteropHelper(CommonHelper.view).Handle, 1);
                //SetForegroundWindow(new System.Windows.Interop.WindowInteropHelper(CommonHelper.view).Handle);
              
                MessageBox.Show("该程序重复开启");
                Application.Current.Shutdown(); 
                return;
            }          
            Readconfig();

            // OpenFileDialog openFileDialog1 = new OpenFileDialog();

            // openFileDialog1.Filter = "文本文件(*.txt)|*.txt|(*.rtf)|*.rtf";

            //if ((bool)openFileDialog1.ShowDialog())

            // { }
        }

     public     void Readconfig()
        {
            BTN_1.Content = ConfigurationManager.AppSettings["Name1"];
            BTN_2.Content = ConfigurationManager.AppSettings["Name2"];
            BTN_3.Content = ConfigurationManager.AppSettings["Name3"];
            BTN_4.Content = ConfigurationManager.AppSettings["Name4"];
            BTN_5.Content = ConfigurationManager.AppSettings["Name5"];
            BTN_6.Content = ConfigurationManager.AppSettings["Name6"];
            BTN_7.Content = ConfigurationManager.AppSettings["Name7"];
            BTN_8.Content = ConfigurationManager.AppSettings["Name8"];
            BTN_9.Content = ConfigurationManager.AppSettings["Name9"];
            BTN_10.Content = ConfigurationManager.AppSettings["Name10"];
            No1_adress = ConfigurationManager.AppSettings["Path1"];
            No2_adress = ConfigurationManager.AppSettings["Path2"];
            No3_adress = ConfigurationManager.AppSettings["Path3"];
            No4_adress = ConfigurationManager.AppSettings["Path4"];
            No5_adress = ConfigurationManager.AppSettings["Path5"];
            No6_adress = ConfigurationManager.AppSettings["Path6"];
            No7_adress = ConfigurationManager.AppSettings["Path7"];
            No8_adress = ConfigurationManager.AppSettings["Path8"];
            No9_adress = ConfigurationManager.AppSettings["Path9"];
            No10_adress = ConfigurationManager.AppSettings["Path10"];

        }

        private void BTN_1_Click(object sender, RoutedEventArgs e)
        {
            string v_OpenFolderPath = @No1_adress;
            System.Diagnostics.Process.Start("explorer.exe", v_OpenFolderPath);
        }

        private void BTN_2_Click(object sender, RoutedEventArgs e)
        {
            string v_OpenFolderPath = @No2_adress;
            System.Diagnostics.Process.Start("explorer.exe", v_OpenFolderPath);
        }

        private void BTN_3_Click(object sender, RoutedEventArgs e)
        {
            string v_OpenFolderPath = @No3_adress;
            System.Diagnostics.Process.Start("explorer.exe", v_OpenFolderPath);
        }

        private void BTN_4_Click(object sender, RoutedEventArgs e)
        {
            string v_OpenFolderPath = @No4_adress;
            System.Diagnostics.Process.Start("explorer.exe", v_OpenFolderPath);
        }

        private void BTN_5_Click(object sender, RoutedEventArgs e)
        {
            string v_OpenFolderPath = @No5_adress;
            System.Diagnostics.Process.Start("explorer.exe", v_OpenFolderPath);
        }

        private void BTN_6_Click(object sender, RoutedEventArgs e)
        {
            string v_OpenFolderPath = @No6_adress;
            System.Diagnostics.Process.Start("explorer.exe", v_OpenFolderPath);
        }

        private void BTN_7_Click(object sender, RoutedEventArgs e)
        {
            string v_OpenFolderPath = @No7_adress;
            System.Diagnostics.Process.Start("explorer.exe", v_OpenFolderPath);
        }

        private void BTN_8_Click(object sender, RoutedEventArgs e)
        {
            string v_OpenFolderPath = @No8_adress;
            System.Diagnostics.Process.Start("explorer.exe", v_OpenFolderPath);
        }

        private void BTN_9_Click(object sender, RoutedEventArgs e)
        {
            string v_OpenFolderPath = @No9_adress;
            System.Diagnostics.Process.Start("explorer.exe", v_OpenFolderPath);
        }

        private void BTN_10_Click(object sender, RoutedEventArgs e)
        {
            string v_OpenFolderPath = @No10_adress;
            System.Diagnostics.Process.Start("explorer.exe", v_OpenFolderPath);
        }



        private void Set_Click(object sender, RoutedEventArgs e)
        {
            Set set = new Set();
            set.Show();
            this.Close();

        }


        
    }
}

标签: 桌面 工具 操作

实例下载地址

C# 快速打开文件夹(桌面快捷操作工具)

不能下载?内容有错? 点击这里报错 + 投诉 + 提问

好例子网口号:伸出你的我的手 — 分享

网友评论

发表评论

(您的评论需要经过审核才能显示)

查看所有0条评论>>

小贴士

感谢您为本站写下的评论,您的评论对其它用户来说具有重要的参考价值,所以请认真填写。

  • 类似“顶”、“沙发”之类没有营养的文字,对勤劳贡献的楼主来说是令人沮丧的反馈信息。
  • 相信您也不想看到一排文字/表情墙,所以请不要反馈意义不大的重复字符,也请尽量不要纯表情的回复。
  • 提问之前请再仔细看一遍楼主的说明,或许是您遗漏了。
  • 请勿到处挖坑绊人、招贴广告。既占空间让人厌烦,又没人会搭理,于人于己都无利。

关于好例子网

本站旨在为广大IT学习爱好者提供一个非营利性互相学习交流分享平台。本站所有资源都可以被免费获取学习研究。本站资源来自网友分享,对搜索内容的合法性不具有预见性、识别性、控制性,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,平台无法对用户传输的作品、信息、内容的权属或合法性、安全性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论平台是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二与二十三条之规定,若资源存在侵权或相关问题请联系本站客服人员,点此联系我们。关于更多版权及免责申明参见 版权及免责申明

;
报警