I want to check if two strings are paths to the same file or folder.
I've seen two questions dealing with this: C# Canonical file names and How can one get an absolute or normalized file path in .NET? .
All answers on both are wrong.
On Windows C:\A.TXT
is the same file as c:\a.txt
. AFAIK on UNIX/LINUX it's not, and on MacOS it depends on the user. (The code might be used on .Net MAUI on different OSs.) And it might depend on the file system even within one OS. Non of the answers there address that. But over a decade has passed since those questions were asked, and that's a lot in computer-years.
So, does .Net (perhaps .Net 7.0) have something for this?
More info: I don't want to touch the file system such as by opening both files and checking whether both point to the same one. I just want to do a text comparison. And I don't care about "different" files pointing to the same file such as by symbolic links etc. so it's fine if the files are considered different by whatever the answer is, even though they point to the same actual file.
EDIT
Some of the paths will be stored, and I need to know that they point to the same file if the user changed from uppercase to lowercase (on Windows). I also need a durable way to check file systems and OSs. Something that will be updated if filesystems will change etc. Like for example NTFS case-sensitive NTFS folders which most commentators here seem not to know about. There might be other pitfalls as well.
Either a Canonical(path)
or a AreSame(path1, path2)
would be welcome.