最新下载
热门教程
- 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;
}
相关文章
- B站视频APP下载入口-手机版免费看大片动漫电视剧在线APP下载 12-12
- 知乎网页版入口在哪 一键直达知乎官网 12-12
- 学习通网页版登录入口-一键直达学习通主页 12-12
- 尾巴漫画官方免费下载入口-尾巴漫画app2025最新无广告版漫画畅读 12-12
- 樱花动漫官方正版下载-樱花动漫官网独家入口 12-12
- Mail.ru官网登录入口 - 一键直达mailru邮箱登录链接 12-12