In both cases using powershell and then the c# methods I can’t seem to get a folder to be created with the same name as a file. If the condition is that the file exists already called d and I try to create the folder the new-item -itemtype directory complains that the file already exists.
[quote quote=132833]Files need extension. Provide extension when creating file which will address this problem.
[/quote]
While this is the most common practice to create files with extensions and folders without extension, technically you can create files without an extension and folders with an extension.
It’s only the attribute which makes the difference.
Look at the Mode property of the following examples.
Creating file and folder WITHOUT an extension
PS C:\Temp> New-Item d -ItemType File
Directory: C:\Temp
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a---- 05-Jan-19 10:33 0 d
PS C:\Temp> Remove-Item d
PS C:\Temp> New-Item d -ItemType Directory
Directory: C:\Temp
Mode LastWriteTime Length Name
---- ------------- ------ ----
d----- 05-Jan-19 10:33 d
PS C:\Temp>
Probably that would be a wrong usage on files with having a slash at the end. I think it tries assumes it as a directory and tries gets the items inside it which is not available, which works for a directory even without any child items. But it should ideally trim the slash and get the desired result.
If we do tab completion, it shows the slash at the end only for directories and not for the files .