'Naming convention for variables containing file path or its parts

What are standard or most self-descripting variable names for variables with following values? (Consider them from perspective of File.Ext)

// Windows environment
var0 = "C:\Folder_A\Folder_B\Folder_C\File.Ext"
var1 = "C:\"
var2 = "C:\Folder_A\"
var3 = "C:\Folder_A\Folder_B\"
var4 = "C:\Folder_A\Folder_B\Folder_C\"
var5 = "File"
var6 = "Ext"
var7 = ".Ext"

This is what comes to my unexperienced mind:

  1. FullPath
  2. Drive
  3. ???
  4. ???
  5. ParentFolderPath
  6. Filename
  7. Extension
  8. FullExtension

Also what is Windows standard or best practice for storing folder paths - with or without the last \?
Same for extension - with or without .?



Solution 1:[1]

filePath = "C:\Folder_A\Folder_B\Folder_C\File.Ext"
rootDirectory = "C:\"
directoryPath = "C:\Folder_A\"
anotherDirectoryPath = "C:\Folder_A\Folder_B\"
aThirdDirectoryPath = "C:\Folder_A\Folder_B\Folder_C\"
filenameSansSuffix = "File"
fileSuffix = "Ext"
anotherDefinitionOfFileSuffix = ".Ext"

It is more natural to define directory paths without a trailing backslash.

When it comes to file extensions I usually include the dot. Also, in Windows Batch scripting, for instance, the modifier ~x results in the file extension including the dot (when i tried it).

%~xI Expands %I to a file name extension only.

https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/for

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1