【发布时间】:2022-12-12 12:03:05
【问题描述】:
这可能是一个微不足道的问题,但我试图了解在这种情况下使用的这两种不同 API 之间的区别。似乎它们是相同的。
我写了一个快速测试程序并在调试模式下查看返回值,这两个 API 返回的值是相同的:
var result = Path.GetFullPath("."); -> ..\source\\repos\\TestingApp\\TestingAppDotNet\\bin\\Debug
string path = Directory.GetCurrentDirectory(); -> ..\source\\repos\\TestingApp\\TestingAppDotNet\\bin\\Debug
这更像是个人喜好吗?
【问题讨论】:
-
GetFullPath() 下有大量代码来处理可能格式错误的参数值。使用 GetCurrentDirectory() 跳过所有代码。
标签: c#