首页 > 编程语言 >C#获取exe所在路径和dll所在路径

C#获取exe所在路径和dll所在路径

时间:2023-07-10 15:22:42浏览次数:40  
标签:xxx string 所在 路径 System exe result str

 

exe所在路径

 转:C#获取当前程序运行路径的方法集合 - 魔法皇帝 - 博客园 (cnblogs.com)   //获取和设置包含该应用程序的目录的名称。(推荐)
string str = System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase;
result: X:\xxx\xxx\ (.exe文件所在的目录+"\")

//获取启动了应用程序的可执行文件的路径,不包括可执行文件的名称。
string str = System.Windows.Forms.Application.StartupPath;
result: X:\xxx\xxx (.exe文件所在的目录)     //获取当前进程的完整路径,包含文件名(进程名)。
string str = this.GetType().Assembly.Location;
result: X:\xxx\xxx\xxx.exe (.exe文件所在的目录+.exe文件名)

//获取新的 Process 组件并将其与当前活动的进程关联的主模块的完整路径,包含文件名(进程名)。
string str = System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName;
result: X:\xxx\xxx\xxx.exe (.exe文件所在的目录+.exe文件名)

//获取和设置当前目录(即该进程从中启动的目录)的完全限定路径。
string str = System.Environment.CurrentDirectory;
result: X:\xxx\xxx (.exe文件所在的目录)

//获取当前 Thread 的当前应用程序域的基目录,它由程序集冲突解决程序用来探测程序集。
string str = System.AppDomain.CurrentDomain.BaseDirectory;
result: X:\xxx\xxx\ (.exe文件所在的目录+"\")



//获取启动了应用程序的可执行文件的路径,包括可执行文件的名称。
string str = System.Windows.Forms.Application.ExecutablePath;
result: X:\xxx\xxx\xxx.exe (.exe文件所在的目录+.exe文件名)

//获取应用程序的当前工作目录(不可靠)。
string str = System.IO.Directory.GetCurrentDirectory();
result: X:\xxx\xxx (.exe文件所在的目录)  

dll所在路径

string path8 = System.Reflection.Assembly.GetExecutingAssembly().Location;

string path9 = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);

标签:xxx,string,所在,路径,System,exe,result,str
From: https://www.cnblogs.com/htj10/p/17541244.html

相关文章

  • ionic cordova 打包Rlease版本包出现异常Execution failed for task ':app:mergeRelea
    异常: 解决方法:找到android=》app下的build.gradle文件,如下增加如下配置 运行ioniccordovabuildandroid--release打包语句正常执行 ......
  • exe反编译工具IDA
    《竞学实训》报告      学      院 :网络空间安全学院专      业 :学生学号:学生姓名:     二〇二三年七月           实验 MalwareAnalysis 一.实验目的掌握MalwareAnalysis的方法。二.实验......
  • Python调用 JS -PyExecJS, Python 调用 JS -js2py
    Python调用JS-PyExecJS日常Web端爬虫过程中,经常会遇到参数被加密的场景,因此,我们需要分析网页源代码通过调式,一层层剥离出关键的JS代码,使用Python去执行这段代码,得出参数加密前后的Python实现//计算两个数的和functionadd(num1,num2){returnnum1+num2;}......
  • python打包Windows.exe程序(pyinstaller)
    python打包Windows.exe程序(pyinstaller)基础命令pipinstallpyinstaller使用pip命令来安装pyinstaller模块。-F:pyinstaller-Fhello.py-phello2.py-D:pyinstaller-Dhello.py-phello2.py-i:pyinstaller-itb.ico-Fhello.py-phello2.py其中前一个文件hel......
  • (文件[夹]批量分类整理_多级匹配_交叉匹配_路径结构交叉调整)文件[夹]批量复制
    首先,需要用到的这个工具:度娘网盘提取码:qwu2蓝奏云提取码:2r1z 如果没有使用过此工具,建议阅读此教程前,先看下这篇文章:https://www.cnblogs.com/Nathan-Young/p/14367685.html原理:对来源路径和终点路径  多次提取出关键词,再自由组合成 匹配词 情景再现:我这里有8张......
  • python 获取动态库 lib-dynload 路径
    动态库lib-dynload路径python3-c'importrandomasm;print(m.__file__)'参考;https://blog.csdn.net/jaket5219999/article/details/53512071......
  • mybatis: 正确使用mybatis中的mapperLocations配置多个xml扫描路径
    <!--myBatis文件--><beanid="sqlSessionFactory"class="org.mybatis.spring.SqlSessionFactoryBean"><propertyname="dataSource"ref="dataSource"/><!--自动扫描entity目录,省掉Configu......
  • 【WALT】scale_exec_time() 代码详解
    @目录【WALT】scale_exec_time()代码详解代码展示代码逻辑:为什么归一化?⑴ 将CPUcycles转换为CPU当前频率⑵ 归一化delta【WALT】scale_exec_time()代码详解代码版本:Linux4.9android-msm-crosshatch-4.9-android12代码展示staticinlineu64scale_exec_time(u64delt......
  • 解决基于WordNet的路径相似度的具体操作步骤
    基于WordNet的路径相似度WordNet是一个广为人知的英语词汇数据库,其中包含了大量的单词和它们之间的关系。在自然语言处理中,WordNet可以用于词义相似度计算,其中一种常用的方法是基于WordNet的路径相似度。路径相似度是通过计算两个词语在词汇网络中的最短路径长度来衡量它们的语义......
  • docker-compose相对路径编译
    可以通过指定context来设置docker-compose的工作路径,../表示当前路径的父路径。 version:'3'services:test:build:context:../dockerfile:apis/app/test/Dockerfileimage:testcontainer_name:testports:-"8000:8000"......