110,502
社区成员
发帖
与我相关
我的任务
分享
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;
namespace OpenFileCursor
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
string pathString;//文件路径
string path1;//文件夹路径
/// <summary>
/// 浏览按钮事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btnBrowse_Click(object sender, EventArgs e)
{
openFileDialog1.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);//定义默认打开位置
openFileDialog1.ShowDialog();//显示打开文件的窗口
pathString = openFileDialog1.FileName;//获取选择的文件路径
path1 = System.IO.Path.GetDirectoryName(pathString) + @"\";//只获取路径不获取文件名
}
/// <summary>
/// 打开文件夹按钮事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btnOpenFiles_Click(object sender, EventArgs e)
{
System.Diagnostics.Process.Start("explorer.exe", path1);
}
}
}
/// <summary>
/// 打开文件夹按钮事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btnOpenFiles_Click(object sender, EventArgs e)
{
System.Diagnostics.Process.Start("explorer.exe", path1);
}