加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

C# 获得运行时的各种目录以及当前用户的桌面,收藏夹,缓存等系

发布时间:2020-12-15 17:53:11 所属栏目:百科 来源:网络整理
导读:今天PHP站长网 52php.cn把收集自互联网的代码分享给大家,仅供参考。 Assembly myAssembly = Assembly.GetEntryAssembly();string path = myAssembly.Location;DirectoryInfo dr = new DirectoryInfo(path);path=dr.Paren

以下代码由PHP站长网 52php.cn收集自互联网

现在PHP站长网小编把它分享给大家,仅供参考

Assembly myAssembly = Assembly.GetEntryAssembly();
string path = myAssembly.Location;
DirectoryInfo dr = new DirectoryInfo(path);
path=dr.Parent;  //当前目录的上一级目录
System.Environment.CurrentDirectory;
//例: c:test
Application.ExecutablePath;(包括名称)
//例: c:testmyapp.exe
Application.StartupPath;(不包括名称)
//例: c:test
string str = System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName;
result: X:xxxxxxxxx.exe (.exe文件所在的目录+.exe文件名)
string str = System.Environment.CurrentDirectory;
string str = System.AppDomain.CurrentDomain.BaseDirectory;
string str = System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase;
string str = System.Windows.Forms.Application.StartupPath;
string str = System.Windows.Forms.Application.ExecutablePath;
string str = System.IO.Directory.GetCurrentDirectory();
System.Environment.GetFolderPath(System.Environment.SpecialFolder.Favorites)
System.Environment.GetFolderPath(System.Environment.SpecialFolder.Desktop)

以上内容由PHP站长网【52php.cn】收集整理供大家参考研究

如果以上内容对您有帮助,欢迎收藏、点赞、推荐、分享。

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读