获取程序集路径 父路径 c#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Reflection;
using System.IO;
namespace ConsoleApplication9
{
    class Program
    {
        static void Main(string[] args)
        {
            string padh = Assembly.GetExecutingAssembly().Location;
            padh = Path.GetDirectoryName(padh);
            Console.WriteLine(Assembly.GetExecutingAssembly().Location);
            Console.WriteLine(Directory.GetParent(padh));
            Console.ReadKey();

        }
    }
}
时间: 2024-08-09 23:54:00

获取程序集路径 父路径 c#的相关文章

Windows Server 2003 中IIS启用父路径

什么是父路径 父路径简单理解指的就是上一层文件夹的路径 开启父路径的主要作用: 启用父路径,ASP页面如果遇到了  include file = ../header.asp  这样的代码,此项必须选上‘启用父路径’ . (../) 表示上级目录下的 header.asp 页面,是用相对路径来表示的. 如果 IIS页面中设置的 ‘启用父路径’ 没有开启的情况下,访问此页面就会报错,因为当前的 IIS 设置不允许使用(..)方式访问父路径,需要将这个数值设定为 true. 启用父路径指定 ASP 页

python 获取当前文件夹路径及父级目录的几种方法

获取当前文件夹路径及父级目录: import os current_dir = os.path.abspath(os.path.dirname(__file__)) print(current_dir) #F:\project\pritice current_dir1 = os.path.dirname(__file__) print(current_dir1) #F:/project/pritice parent_path = os.path.dirname(current_dir1) pri

C# Winform中如何获取文件名与文件路径

获取文件名方法: 用System.IO.Path.GetFileName和System.IO.Path.GetFileNameWithoutExtension(无扩展名)的方法 获取文件路径方法: //获取当前进程的完整路径,包含文件名(进程名).string str = this.GetType().Assembly.Location;result: X:\xxx\xxx\xxx.exe (.exe文件所在的目录+.exe文件名) //获取新的 Process 组件并将其与当前活动的进程关联的

C# 获取程序运行时路径

?  前言 开发中,很多时候都需要获取程序运行时路径,比如:反射.文件操作等..NET Framework 已经封装了这些功能,可以很方便的使用. 1.   可使用类 1.   System.AppDomain,程序集:mscorlib.dll. 2.   System.Environment,程序集:mscorlib.dll. 3.   System.IO.Directory,程序集:mscorlib.dll. 4.   System.Reflection.Assembly,程序集:mscor

四种方法获取可执行程序的文件路径(.NET Core / .NET Framework)

原文:四种方法获取可执行程序的文件路径(.NET Core / .NET Framework) 本文介绍四种不同的获取可执行程序文件路径的方法.适用于 .NET Core 以及 .NET Framework. 本文内容 使用程序集信息获取 使用应用程序域信息获取 使用进程信息获取 使用命令行参数获取 总结靠谱的方法 另外,关于以上方法的性能对比,你可以参阅林德熙的博客:[dotnet 获取路径各种方法的性能对比](https://blog.lindexi.com/post/dotnet-%E8%

获取当前程序的路径

获取当前程序所在路径文件1. System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName-获取模块的完整路径. 2. System.Environment.CurrentDirectory-获取和设置当前目录(该进程从中启动的目录)的完全限定目录. 3. System.IO.Directory.GetCurrentDirectory()-获取应用程序的当前工作目录.这个不一定是程序从中启动的目录啊,有可能程序放在C:\ww

JavaScript获取当前url根目录(路径)

jsp: <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%><%@taglib prefix="s" uri="/struts-tags"%><% String path = request.getContextPath(); String basePath = request.getSche

grails、javascript 获取当前部署项目路径

javascript获取当前部署项目路径: 主要用到Location 对象,包含有关当前 URL 的信息,是 Window 对象的一个部分,可通过 window.location 属性来访问. 方法一 (window.document.location.href/window.document.location.pathname) ------------转自网络 function getRootPath_web() { //获取当前网址,如: http://localhost:8083/uim

如何在java类中获取javaWeb的根路径

我们有时候需要在java类中(包括util类等)获取web的根路径,可以通过class类路径来获取: public static String getRealPath(Class clazz) { String url = clazz.getResource("").getPath(); int displace = url.indexOf("WEB-INF"); StringBuffer buffer = new StringBuffer(); for (int