简体   繁体   中英

How to get Relative Path from Files of one chosen Folder?

enter image description here

enter image description here I get only the relative path of the directory/folders but not of the files in it? I can't really find the bug... . I do not understand why it won't get the relative path of the files but of the folders it will.

From MSDN :

Directory.GetFiles Method (String)

Returns the names of files (including their paths) in the specified directory.

So you should do this:

foreach(string filename in Directory.GetFiles(path))
{
    result.Append(Path.GetFileName(filename), "FILE");
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM