获取项目下的文件路径
1、例
//讲稿模板不存在 string noteTemPath = AppDomain.CurrentDomain.BaseDirectory + "DownLoad\\noteMakeDoc.doc"; global::System.IO.File.Copy(noteTemPath, TemPath);
1 try 2 { 3 System.Diagnostics.Process.Start(AppDomain.CurrentDomain.BaseDirectory + ConfigService.SeatURL); 4 } 5 catch (Exception) 6 { 7 MessageBox.Show("系统找不到指定文件!", "错误", MessageBoxButton.OK, MessageBoxImage.Error); 8 }
2、例
1 /// <summary> 2 /// System.ini 配置文件 3 /// </summary> 4 public static string configSystemFilePath = AppDomain.CurrentDomain.BaseDirectory + "/Config/System.ini";
3、例(读取ini文件的特定值)
1 var StartUpExe = Function.IniReadValue("SYSTEM", "StartUpExe", "", AppDomain.CurrentDomain.BaseDirectory + "/Config/System.ini"); 2 System.Diagnostics.Process.Start(StartUpExe);
System.ini文件
[SYSTEM] UserName=人民法院 AppTitle=管理平台 #是否全屏 FullScreen=0 #页面名称控件宽度 TopicTitleWidth=700 #大屏客户端地址路径 StartUpExe=C:/Program Files (x86)/WPS-Interactive/WPS-Interactive.exe
本文介绍了几种在项目中获取特定文件路径的方法,包括使用AppDomain获取当前目录并结合相对路径来定位文件,以及通过配置文件读取文件路径。示例展示了如何复制文件和启动外部程序。
1111

被折叠的 条评论
为什么被折叠?



