gpt4 book ai didi

c# - Directory.GetDirectories(path) 返回完整路径还是仅返回名称?

转载 作者:太空狗 更新时间:2023-10-30 00:09:21 27 4
gpt4 key购买 nike

在 MSDN 文档中,它说它只返回目录名(“返回值类型: ...包含路径中子目录名称的字符串类型数组。”),但是在他们的示例代码中,他们递归而不连接它们,所以这是否意味着他们返回完整路径?

即他们的示例代码:

public static void ProcessDirectory(string targetDirectory) 
{
// Process the list of files found in the directory.
string [] fileEntries = Directory.GetFiles(targetDirectory);
foreach(string fileName in fileEntries)
ProcessFile(fileName);<p></p>

<pre><code> // Recurse into subdirectories of this directory.
string [] subdirectoryEntries = Directory.GetDirectories(targetDirectory);
foreach(string subdirectory in subdirectoryEntries)
ProcessDirectory(subdirectory);
}
</code></pre>

<p></p>

如果 GetDirectories 方法只返回目录名,将无法工作!

最佳答案

function's MSDN page 中所述:

The names returned by this method are prefixed with the directory information provided in path [ed: the parameter to the function].

关于c# - Directory.GetDirectories(path) 返回完整路径还是仅返回名称?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1461652/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com