如何在选择文件时在文件夹之间向上移动? [英] How to move up between folders while choosing a file?

查看:745
本文介绍了如何在选择文件时在文件夹之间向上移动?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个项目文件夹。我演示了我的文件夹:



一个Project_Folder

- bin

- Debug(默认文件夹,如果我使用路径如:@FileName

B Project_Folder

- bin

- 调试

--- RAF.exe



所以从默认文件夹(A Project_Folder)我想从B部分选择RAF.exe文件。



我尝试过:



 System.Diagnostics.Process.Start (@\RAF\bin\Debug\RAF.exe..\..\..\..\); 

解决方案

对于初学者,不要那样做。

要上去,它必须继续exe文件名:

 \RAF\bin\Debug\..\..\..\..\RAF.exe 

而且由于最初的反斜杠意味着从根目录,你无论如何都不能达到那么多级别。

但是......正如我所说,不要这样做。在我说这很简单:在生产中文件夹布局将不相同,甚至关闭。安装后,您的应用程序将位于程序文件下 - 这不一定位于任何磁盘的根目录下 - 以及应用程序名称。 Debug文件夹几乎肯定不可用,或者可能是bin文件夹。而不是硬连线位置并假设文件夹结构不太可能存在,请使用配置文件存储目标EXE的绝对路径,并在程序首次安装时设置该路径。 / BLOCKQUOTE>

I have two project folders. I demonstrate my folders:

A Project_Folder
- bin
-- Debug (default folder if I use a path like : @"FileName"
B Project_Folder
- bin
-- Debug
--- RAF.exe

So from the default folder (A Project_Folder) I would like to choose the RAF.exe file from the B section.

What I have tried:

System.Diagnostics.Process.Start(@"\RAF\bin\Debug\RAF.exe..\..\..\..\");

解决方案

For starters, don't do it like that.
To go up, it would have to proceed the exe file name:

\RAF\bin\Debug\..\..\..\..\RAF.exe

And since an initial backslash means "from the root directory" you can't go up that many levels anyway.
But ... as I said, don't do that. The reason I say that is simple: in production the folder layout will not be the same, or even close. Once installed, you app will be under Program Files - which isn't necessarily under the root directory of any disk - and the app name. The Debug folder will almost certainly not be available, or probably the bin folder. Instead of "hard wiring" the location and assuming a folder structure that
is unlikely to exist, use a configuration file to store the absolute path to your target EXE and set that when your program first installs.


这篇关于如何在选择文件时在文件夹之间向上移动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆