c#获取目录
2024-08-28 17:38:38
获取程序目录
string s = System.IO.Directory.GetCurrentDirectory();
Console.WriteLine(s);// C:\Users\r-\documents\visual studio 2013\Projects\TestMVC\ConsoleApplication1\bin\Debug
s=s.Substring(,s.LastIndexOf("\\"));
Console.WriteLine(s);//C:\Users\r-\documents\visual studio 2013\Projects\TestMVC\ConsoleApplication1\bin
s=s.Substring(, s.LastIndexOf("\\"));
Console.WriteLine(s);//C:\Users\r-\documents\visual studio 2013\Projects\TestMVC\ConsoleApplication1
其他总结
//获取到bin目录的下层路径:bin\Debug\ string aa = System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase; string cc = System.AppDomain.CurrentDomain.BaseDirectory; //获取到bin目录:bin\Debug string dd = System.Environment.CurrentDirectory; string ee = System.IO.Directory.GetCurrentDirectory(); string ff = System.Windows.Forms.Application.StartupPath; //获取程序.exe string bb = System.Windows.Forms.Application.ExecutablePath;
最新文章
- [UE4][Custom Animation Graph Node]Evaluate Pose by Curve
- codeforces 340C Tourist Problem
- Mybatis Physical Pagination
- 将Spark中CompactBuf转换为String
- Html - Footer
- RM报表里的变量
- 日历控件修改的JS代码
- bzoj2734 集合选数
- button 禁止
- 内置函数 -- filter 和 map
- JFinal项目发送邮件——jfinal-mail-plugin
- 随手一记,maven打包
- “/";应用程序中的服务器错误
- React高级指引
- 【转】flannel网络的VXLAN及host-gw
- RoR - Introduction to Active Record
- vue教程自学笔记(三)
- VIVADO 入门之仿真与逻辑分析仪使用
- Inferred type 'S' for type parameter 'S' is not within its bound;
- 在VC++中怎样改变控件间的TAB切换顺序?
热门文章
- HashMap vs Hashtable
- 【转】32位plsql连接64位oracle
- poj1753(高斯消元解mod2方程组)
- Jmeter-逻辑控制器之Switch控制器(Switch Controller)
- BZOJ 2725 [Violet 6]故乡的梦 线段树+最短路树
- spring中使用缓存
- C++11 特性:成员函数引用限定 (Reference qualifier)
- ArcGIS-各类问题
- Kibana问题记录:yarn test 运行报错 error Trailing spaces not allowed no-trailing-spaces
- PreparedStatement是如何防止SQL注入的?