【转】C#获取当前路径7种方法

webformvar s = System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName;  //C盘 IIS路径
var s1 = System.Environment.CurrentDirectory; //同上
var s2 = System.IO.Directory.GetCurrentDirectory();//同上
var s3 = System.AppDomain.CurrentDomain.BaseDirectory; //当前项目根目录
var s4 = System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase; //同上

  

winform

System.Windows.Forms.Application.StartupPath
System.Windows.Forms.Application.ExecutablePath
时间: 2024-08-07 16:44:41

【转】C#获取当前路径7种方法的相关文章

C# 获取当前路径7种方法

1 //获取模块的完整路径. 2 string path1 = System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName; 3 //获取和设置当前目录(该进程从中启动的目录)的完全限定目录 4 string path2 = System.Environment.CurrentDirectory; 5 //获取应用程序的当前工作目录 6 string path3 = System.IO.Directory.GetCurre

关于火狐(firefox)及ie下event获取的两种方法

第一种方法: 代码如下: function a(e){ e=e||window.event; alert(e.keyCode); } ie浏览器如下调用 代码如下: <body onclick="a()"> firefox火狐浏览器如下调用 代码如下: <body onclick="a(event)"> 这样就可以调用成功. 这种方法在firefox需要带个参数过去,不是太好,下面介绍第二种方法 . 第二种方法: 代码如下: function

Java反射定义、获取Class三种方法

反射机制的定义: 在运行状态时(动态的),对于任意一个类,都能够得到这个类的所有属性和方法.  对于任意一个对象,都能够调用它的任意属性和方法. Class类是反射机制的起源,我们得到Class类对象有3种方法: 第一种:通过类名获得 Class<?> class = ClassName.class; 第二种:通过类名全路径获得: Class<?> class = Class.forName("类名全路径"); 第三种:通过实例对象获得: Class<?&

获取编辑器两种方法

编辑器,是地图数据进行编辑的主要工具,这个Editor其实当一个新的地图开始时就创建了.事实上,其他ArcMap扩展对象也是在创建地图时产生的. 为了获得这个Editor,可以使用FindExtensionByCLSID 或者FindExtensionByName接口. private IEditor m_editor; private IApplication app; // 方法一:FindExtensionByCLSID ... UID editorUid = new UID(); edi

springmvc——请求参数获取的几种方法

方法一: 通过@PathVariabl注解获取路径中传递参数 JAVA @RequestMapping(value = "/{id}/{str}") public ModelAndView helloWorld(@PathVariable String id, @PathVariable String str) { System.out.println(id); System.out.println(str); return new ModelAndView("/helloW

Struts2获取request三种方法

struts2里面有三种方法可以获取request,最好使用ServletRequestAware接口通过IOC机制注入Request对象. 在Action中获取request方法一: 在Action中的代码: Map request = (Map)ActionContext.getContext().get("request"); List<Task> tasks = taskManager.findAll(); request.put("tasks"

Spring3 MVC请求参数获取的几种方法

一.      通过@PathVariabl获取路径中的参数 @RequestMapping(value="user/{id}/{name}",method=RequestMethod.GET) public String printMessage1(@PathVariable String id,@PathVariable String name, ModelMap model) { System.out.println(id); System.out.println(name);

springmvc请求参数获取的几种方法

1.直接把表单的参数写在Controller相应的方法的形参中,适用于get方式提交,不适用于post方式提交. /** * 1.直接把表单的参数写在Controller相应的方法的形参中 * @param username * @param password * @return */ @RequestMapping("/addUser1") public String addUser1(String username,String password) { System.out.pri

SPRING MVC 的请求参数获取的几种方法

通过@PathVariabl注解获取路径中传递参数 JAVA @RequestMapping(value = "/{id}/{str}") public ModelAndView helloWorld(@PathVariable String id, @PathVariable String str) { System.out.println(id); System.out.println(str); return new ModelAndView("/helloWorld&