Benjamin
Benjamin

Reputation: 10393

What's the difference \\.\C: and \\.\C:\

In MSDN,

String Meaning
\\.\C: Opens the C: volume.
\\.\C:\ Opens the file system of the C: volume.

I could open \\.\C: volume device.
But I couldn't open \\.\C:\ directory by CreateFile.

How can I open the directory by CreateFile with \\.\ prefix.
And if I open the directory, what can I do by using the handle.

Are C:\ and \\.\C:\ same?

Upvotes: 0

Views: 199

Answers (1)

SpectralAngel
SpectralAngel

Reputation: 48

From the same MSDN page:

When opening a volume or removable media drive (for example, a floppy disk drive or flash memory thumb drive), the lpFileName string should be the following form: \.\X:. Do not use a trailing backslash (), which indicates the root directory of a drive. The following table shows some examples of drive strings.

Most likely since the WinAPI does not support the trailing backslash they mean the same but behave differently

Upvotes: 1

Related Questions