How would I compare 2 strings to determine if they refer to the same path in Win32 using C/C++?
While this will handle a lot of cases it misses some things:
_tcsicmp(szPath1, szPath2) == 0
For example:
forward slashes / backslashes
relative / absolute paths.
[Edit] Title changed to match an existing C# question.
They indicate that the path should be passed to the system with minimal modification, which means that you cannot use forward slashes to represent path separators, or a period to represent the current directory, or double dots to represent the parent directory.
Click the Start button and then click Computer, click to open the location of the desired file, hold down the Shift key and right-click the file. Copy As Path: Click this option to paste the full file path into a document. Properties: Click this option to immediately view the full file path (location).
Example. If the current directory is C:\Windows, the relative path to the executable for the game of Solitaire, which is located in the current directory, is simply the name of the executable – sol.exe. If the current directory is C:\Windows\System, the relative path to Solitaire is .. \sol.exe.
File paths specify the location of individual files. They are used to give files access to one another and they are of two types : Absolute and Relative. Relative file paths on the hand points to the location of files in the root folder of an individual web project with reference to the current working file.
Open both files with CreateFile
, call GetFileInformationByHandle
for both, and compare dwVolumeSerialNumber
, nFileIndexLow
, nFileIndexHigh
. If all three are equal they both point to the same file:
GetFileInformationByHandle
function
BY_HANDLE_FILE_INFORMATION
Structure
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With