最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
C# webForm 文件访问与获取应用程序当前路径
时间:2022-06-25 08:29:24 编辑:袖梨 来源:一聚教程网
winfom获取应用程序当前路径
system.diagnostics.process.getcurrentprocess().mainmodule.filename;
//获取新的 process 组件并将其与当前活动的进程关联的主模块的完整路径,包含文件名(进程名)。
//返回 e:c#学习获取当前路径获取当前路径bindebug获取当前路径.exe system.appdomain.currentdomain.setupinformation.applicationbase;
//获取和设置包含该应用程序的目录的名称。
//返回 e:c#学习获取当前路径获取当前路径bindebug
system.windows.forms.application.startuppath;
//获取启动了应用程序的可执行文件的路径,不包括可执行文件的名称。
//返回 e:c#学习获取当前路径获取当前路径bindebug
system.windows.forms.application.executablepath;
//获取启动了应用程序的可执行文件的路径,包括可执行文件的名称。
//返回 e:c#学习获取当前路径获取当前路径bindebug获取当前路径.exe system.io.directory.getcurrentdirectory();
//获取应用程序的当前工作目录(不可靠)。
//返回 e:c#学习获取当前路径获取当前路径bindebug
this.gettype().assembly.location;
//获取当前进程的完整路径,包含文件名(进程名)。
//遗憾的静态方法无法使用
//返回 e:c#学习获取当前路径获取当前路径bindebug获取当前路径.exe
string path = ""; if (system.environment.currentdirectory == appdomain.currentdomain.basedirectory)//windows应用程序则相等 { path = appdomain.currentdomain.basedirectory; } else { path = appdomain.currentdomain.basedirectory + "bin"; }
c# webform 文件访问
string[] getdirectoryfiles(string dirvpath, string pattern)
{
string dirvpathrooted = string.concat(
httpcontext.current.request.applicationpath.tolower(),
dirvpath);
string dirpath = httpcontext.current.server.mappath(dirvpathrooted);string[] files = directory.getfiles(dirpath, pattern, searchoption.alldirectories);
string[] includes = new string[files.length];
for (int i = 0; i {
includes[i] = files[i]
.replace(dirpath, dirvpath) // replace physical root by virtual root
.replace('', '/');
}
return includes;
}
相关文章
- 免费漫画阅读站旧版入口-免费漫画在线观看全攻略 02-22
- 微信模拟器免费版3.0下载最新版本-微信聊天模拟器手机版app下载安装入口 02-22
- etsy官网入口-etsy官方网页版网址 02-22
- 秋蝉漫画免费阅读入口-秋蝉韩漫土豪版在线观看地址 02-22
- deepseek网页版极速体验-deepseek官网一键直达 02-22
- 歪歪韩漫-免费阅读登录入口2026 02-22