- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试执行一个工具exe,它与主exe位于同一目录中。为此,我尝试首先使用 Assembly.GetExecutingAssembly 获取进程的 exe 名称,然后使用 IO.Path.GetDirectoryName 获取目录
//1
String exePath = System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase;
//2
String ncpath = System.IO.Path.GetDirectoryName(exePath);
1 返回“file:///C:/Development/RC_trunk/bin/Release/ResultConfirmation.EXE”它是一个 URI。不完全是我需要的,但还可以。
2 返回“file:\C:\Development\RC_trunk\bin\Release” 这似乎是一个简单的 [/]+ 到\替换。
我是否使用了错误的 API 来解决我的问题?
附注IDE是VS2008
最佳答案
要获取应用程序目录,请尝试AppDomain.CurrentDomain.BaseDirectory
。
看看Best way to get application folder path了解访问目录的其他方式。
关于c# - System.IO.Path.GetDirectoryName 使路径无效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19757904/
当我使用OpenFileDialog 打开文件时,当然我需要获取文件目录 及其名称 来加载文件。(加载 xml,访问我需要完整路径的文件。) opd 是 OpenFileDialog
我正在尝试执行一个工具exe,它与主exe位于同一目录中。为此,我尝试首先使用 Assembly.GetExecutingAssembly 获取进程的 exe 名称,然后使用 IO.Path.GetD
我正在尝试执行与主 exe 位于同一目录中的工具 exe。为此,我尝试首先使用 Assembly.GetExecutingAssembly 获取进程的 exe 名称,然后使用 IO.Path.GetD
我在 .Net Core 2 中有一个测试用例,我在其中向 Path.GetDirectoryName 提供以下输入。 @"C:" + Path.DirectorySeparatorChar 当我在测
Path.GetDirectoryName(@"C:\\"); 返回 null 和 Path.GetDirectoryName(@"C:\\Foo"); 返回 C:\ 虽然这正是 documentat
public static void Main() { // testing file name var fileName = "\\\\server7\\EmailA
我发现在下面的代码中使用 Path.GetFileName() 可以按照我的意图工作,并为我提供正确文件夹的名称,但是如果我使用 Path.GetDirectoryName() 它返回父 (UserG
string path = Path.GetDirectoryName( Assembly.GetAssembly(typeof(MyClass)).Code
我想使用斜杠而不是反斜杠,因为我的应用程序与 ftp 通信,不允许将反斜杠作为目录分隔符。 有没有自己写方法的捷径/配置? 最佳答案 窃取@Tejs 评论作为答案。 由于 GetDirectoryNa
我正在尝试构建我的 .Net Core 解决方案,但收到了我无法弄清楚的错误消息; 2017-05-22T14:30:56.2490242Z _TransformWebConfig: 2017-05-
我是一名优秀的程序员,十分优秀!