我怎样才能获得一个给定的路径的完整路径(可以是一个目录或文件,甚至是完整路径)使用C#?路径、是一个、完整、文件

2023-09-06 05:31:09 作者:惊鸿过横塘

我得到的是使用最近的新的FileInfo(路径).FullPath ,但据我所知FileInfo的是文件而已,没有目录。

The closest I get is using new FileInfo(path).FullPath, but as far as I know FileInfo is for files only, not directory.

另请参阅我的意见Jon飞碟双向的答案这里上下文。

See also my comments to Jon Skeet's answer here for context.

推荐答案

Path类还为您提供了很多很好的方法和属性,例如: GetFullPath()。请参见 MSDN 的所有细节。

The Path class also gives you a lot of nice methods and properties, e.g. GetFullPath(). See MSDN for all details.