获取文件路径

1.打开单个文件,获取文件名
private void On_Click()
{
  string filename="";

  OpenFileDialog Dialog = new OpenFileDialog();

  Dialog.Filter = "(*.ifc)|";

  if (Dialog.ShowDialog() == DialogResult.OK)
  {
    filename = Path.GetFileNameWithoutExtension(Dialog.FileName);
  }
  else
  {
    MessageBox.Show("未选择");
  }
}


2.打开文件夹,获取文件名路径
private void On_Click()
{
  string[] filepath=null;

  FolderBrowserDialog Dialog = new FolderBrowserDialog();

  Dialog.Description = "";

  if (Dialog.ShowDialog() == DialogResult.OK)
  {
    str = Dialog.SelectedPath;

    filepath = Directory.GetFiles(@str, "*.ifc");
  }
  else
  {
    MessageBox.Show("未选择");
  }
}

3.弹出界面,获取界面选择信息内容
private void On_Click()
{
  Form form = new Form();

  string[] DQ_files = null;

  DialogResult str = form.ShowDialog();

  if (str == DialogResult.OK)
  {
    DQ_files = form.files.Split('@');
  }
  else
  {
    MessageBox.Show("未选择");
  }
}

上一篇:WinForm 关闭登陆窗体,打开主窗体的实现


下一篇:PHP – 按Back按钮后的Session_Destroy