c#怎么获取用户选择文件路径

 时间:2024-10-12 01:16:17

1、// 选择文件:private string SelectPath(){ string path = strin爿讥旌护g.Empty; var openFileDialog = new Microsoft.Win32.OpenFileDialog() { Filter = "Files (*.*)|*.*"//如果需要筛选txt文件("Files (*.txt)|*.txt") }; var result = openFileDialog.ShowDialog(); if (result == true) { path = openFileDialog.FileName; } return path}// 选择路径private string SelectPath(){ string path = string.Empty; System.Windows.Forms.FolderBrowserDialog fbd = new System.Windows.Forms.FolderBrowserDialog(); if (fbd.ShowDialog() == System.Windows.Forms.DialogResult.OK) { path = fbd.SelectedPath; } return path;}

  • Windows11如何设置当前播放声音的所有设备
  • C# 隐藏、显示Excel工作表、行或列
  • git bash怎样创建版本库?
  • 用C#实现带箭头的直线,可调整箭头的大小
  • C#如何设置启动对象
  • 热门搜索
    陕西旅游政务网 重庆旅游景点大全介绍 民丹岛旅游攻略 烟台旅游政务网官网 贵阳的旅游景点 常州旅游局 云南双廊旅游攻略 埃及旅游价格 福建省旅游地图 松原旅游景点大全