5

A dot (.) can be part of a file or directory name including the first and last position. On UNIX a single dot in a path refers to the current directory and can thus always be resolved to a directory whose name is not ..

Is there some way that I can create a directory which is named . on Windows?

phuclv
  • 30,396
  • 15
  • 136
  • 260
Kalle Richter
  • 2,472
  • 6
  • 44
  • 64

2 Answers2

10

No. A single dot means the current directory and 2 dots mean the parent directory, just like on *nix

  • Use a period as a directory component in a path to represent the current directory, for example ".\temp.txt". For more information, see Paths.
  • Use two consecutive periods (..) as a directory component in a path to represent the parent of the current directory, for example "..\temp.txt". For more information, see Paths.

Naming Files, Paths, and Namespaces

In fact a more general rule is that no file can end with a dot in Windows

Do not end a file or directory name with a space or a period. Although the underlying file system may support such names, the Windows shell and user interface does not. However, it is acceptable to specify a period as the first character of a name. For example, ".temp".

See

The reason is because they'll be normalized when passing to Win32 APIs

Some characters will be removed (other than runs of separators and relative segments).

If a segment ends in a single period, that period will be removed. A segment of a single or double period falls under the relative component rule above. A segment of three periods (or more) doesn't hit any of these rules and is actually a valid file/directory name.

If the path doesn't end in a separator, all trailing periods and spaces (charater [sic] code 32 only) will be removed. If the last segment is simply a single or double period it falls under the relative components rule above. This rule leads to the possibly surprising ability to create a directory with a trailing space. You simply need to add a trailing separator to do so.

Path Normalization

That doesn't mean that those files can't be created though, because NTFS namespace is fully POSIX-compatible. You just need to append the \\?\ prefix to disable file name normalization

For file I/O, the "\?" prefix to a path string tells the Windows APIs to disable all string parsing and to send the string that follows it straight to the file system

Naming Files, Paths, and Namespaces

See also

phuclv
  • 30,396
  • 15
  • 136
  • 260
-2

The single dot means the same in MS Operating systems as well. Open a CMD prompt, and type dir . as an experiment. So, the answer to your question is, no.

phuclv
  • 30,396
  • 15
  • 136
  • 260