C#如何推导出相对文件路径文件位于盛大父文件夹?文件、文件夹、路径、盛大

由网友(雅痞)分享简介:我在使用Visual Studio 2005,(.NET版本> 2.0+),以创建一个Windows应用程序。I am using Visual Studio 2005, (.NET version > 2.0+) to create a windows application.根据我的观察,一个文件的相对路径可以...

我在使用Visual Studio 2005,(.NET版本> 2.0+),以创建一个Windows应用程序。

I am using Visual Studio 2005, (.NET version > 2.0+) to create a windows application.

根据我的观察,一个文件的相对路径可以在debug文件夹中创建EXE文件的引用给定的。 例如:如果我给的路径为影像 image.png的文件夹中的文件,图像(这inturn位于Debug文件夹中)加载

As per my observation, the relative path of a file can be given in reference of EXE file created in DEBUG folder. example : if I give path as "imagesimage.png" the file inside the folder "images" (which inturn located in DEBUG folder) is loaded.

我的问题是,如果该文件存在于父文件夹? 假定。调试驻留在BIN的文件夹,并且多了一个文件夹中的图像,我有指向我的code。照片的 (斌/图像/ image.png)

my question is, what if the file exists in a parent folders? suppose that .. "DEBUG" resides in a "BIN" folder and that has one more folder "IMAGES" which I have to point in my code.(bin/images/image.png)

这方面的需要,可避免复制的图像文件夹内的debug文件夹本身或给出绝对路径,但..我想知道是否有任何方式的点家长在相对路径的文件夹

this need can be avoided by copying "IMAGES" folder inside debug folder itself or by giving the absolute path, but .. I want to know if there is any way to point Parent folders in relative path

推荐答案

不。工作?如, ../../ image.png

编辑添加一些细节:根据 MSDN 中,A路径也说是相对的,如果它包含双点;即,两个时期一起在路径的一个组件此特殊说明符用于表示当前目录以上的目录,或称为父目录。

edit to add some detail: as per MSDN, "A path is also said to be relative if it contains "double-dots"; that is, two periods together in one component of the path. This special specifier is used to denote the directory above the current directory, otherwise known as the "parent directory"."

两个这样的双点将让你的盛大父文件夹,在我的例子中

two of these 'double-dots' would get you the grand-parent folder, as in my example.

阅读全文

相关推荐

最新文章