1.asp.net webform 用
“request.physicalapplicationpath获取站点所在虚拟目录的物理路径,最后包含“\”;
2.c# winform 用
a:“application.startuppath”:获取当前应用程序所在目录的路径,最后不包含“\”;
b:“application.executablepath ”:获取当前应用程序文件的路径,包含文件的名称;
c:“appdomain.currentdomain.basedirectory”:获取当前应用程序所在目录的路径,最后包含“\”;
d:“system.threading.thread.getdomain().basedirectory”:获取当前应用程序所在目录的路径,最后包含“\”;
e:“environment.currentdirectory”:获取当前应用程序的路径,最后不包含“\”;
f:“system.io.directory.getcurrentdirectory”:获取当前应用程序的路径,最后不包含“\”;
3.c# windows service
用“appdomain.currentdomain.basedirectory”或“system.threading.thread.getdomain().basedirectory”;
用“environment.currentdirectory”和“system.io.directory.getcurrentdirectory”将得到“ system32”目录的路径;
如果要使用“application.startuppath”或“application.executablepath ”,需要手动添加对“system.windows.forms.dll ”的引用,并在程序开头用“using system.windows.forms”声明该引用;
4.在卸载程序获取系统安装的目录
system.reflection.assembly curpath = system.reflection.assembly.getexecutingassembly();
string path=curpath.location;//得到安装程序类setuplibrary文件的路径,获取这个文件路径所在的目录即得到安装程序的目录
http://blog.163.com/dykj_dxj/blog/static/254925252010830113424205/
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号