最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
C# webForm 文件访问与获取应用程序当前路径
时间:2011-04-15 编辑:简简单单 来源:一聚教程网
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 < files.length; i++)
{
includes[i] = files[i]
.replace(dirpath, dirvpath) // replace physical root by virtual root
.replace('', '/');
}
return includes;
}
-
上一个: c 随机生成字符串或数组方法
-
下一个: asp.net 静态页面生成代码
相关文章
- C#复制数组的两种方式及效率比较解读 10-24
- ASP.NET Identity用法解析 10-24
- ASP.NET MVC使用Identity增删改查用户介绍 10-24
- C语言中atoi函数模拟实现介绍 10-18
- .Net反向代理组件Yarp用法介绍 10-10
- .NET使用YARP通过编码方式配置域名转发实现反向代理教程 10-10