No acces to network folder with name ending in a space

English support forum

Moderators: Hacker, petermad, Stefan2, white

Post Reply
User avatar
Impeeza
Junior Member
Junior Member
Posts: 24
Joined: 2004-04-30, 15:04 UTC

No acces to network folder with name ending in a space

Post by *Impeeza »

Hi, I hope do not duplicating issue:

I didn't noted before, but just after upgrading to Total Commander 9.50 I had to access for the first time to a folder with a odd name:

Code: Select all

\\tsclient\c\$Folder\_Folder2\Folder number three\Folder Fourth\Folder Fifth \
note the ending space of the path name.

I have the opportunity to use Total Commander in both the server (TSCLIENT) and local computer, when in server I try to access the local (for Server) path

Code: Select all

c:\$Folder\_Folder2\Folder number three\Folder Fourth\Folder Fifth \
the access is flawless, even the tab stop header shows the lead space on the folder name.

Then at my local computer, when I try to access the aforementioned server path pressing enter on the folder name "[Folder Fifth ]" there is no error, only get the "Folder Fourth" refreshed.

If I use the Total Commander's "command line" and put either of the commands:

Code: Select all

cd \\tsclient\c\$Folder\_Folder2\Folder number three\Folder Fourth\Folder Fifth \
cd "\\tsclient\c\$Folder\_Folder2\Folder number three\Folder Fourth\Folder Fifth \"
There is no change on the actual folder.

Thanks a lot for your helping.
Impeeza jaja
User avatar
Stefan2
Power Member
Power Member
Posts: 4281
Joined: 2007-09-13, 22:20 UTC
Location: Europa

Re: No acces to network folder with name ending in a space

Post by *Stefan2 »

On which operation system do you fail? Your server is an unix system. yes?
The WindowsTM API do not support trailing blanks on file names. Or did it work with WinExplorer?





 
User avatar
Impeeza
Junior Member
Junior Member
Posts: 24
Joined: 2004-04-30, 15:04 UTC

Re: No acces to network folder with name ending in a space

Post by *Impeeza »

Hi, Both the server and local computer are Windows 10 Pro 1903, I just make the test and open the network path on Windows Explorer (via run dialog or writing directly on the path bar of explorer) and get a empty folder with the "This folder is empty." message.

The folder have several files.

I manually rename the folder and remove the trail space and works perfect on Total Commander and Explorer, even add a extra "A" at end just to test if the problem is for the total length of path, and works fine.
Impeeza jaja
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50873
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: No acces to network folder with name ending in a space

Post by *ghisler(Author) »

How did you share the folder with a trailing space? I have tried this on Windows 10 via Properties - Sharing - Advanced sharing, but Windows removed the trailing space.
Author of Total Commander
https://www.ghisler.com
User avatar
Impeeza
Junior Member
Junior Member
Posts: 24
Joined: 2004-04-30, 15:04 UTC

Re: No acces to network folder with name ending in a space

Post by *Impeeza »

Hi. The shared folder do not have the trailing soace is a subfolder of shared one. But the folder whit name ending on a space was created by a folder tranfered from a SFTP linux server
Impeeza jaja
gdpr deleted 6
Power Member
Power Member
Posts: 872
Joined: 2013-09-04, 14:07 UTC

Re: No acces to network folder with name ending in a space

Post by *gdpr deleted 6 »

Stefan2 wrote: 2020-02-06, 20:05 UTC On which operation system do you fail? Your server is an unix system. yes?
The WindowsTM API do not support trailing blanks on file names. Or did it work with WinExplorer?
While this seems to be correct on the surface, this is not entirely accurate. The Windows API allows you to create (and use) both directories and files(!) having names with trailing spaces. (Windows API != Windows Explorer)

More accurately, many (if not most/all, but who knows) Windows API with parameter(s) for path strings accept any directory/file name with trailing spaces as long such a name is not the very last(!) component in the path string.

A few simple .NET one-liners will demonstrate this (doesn't matter whether you use Core, .NET Framework, or execute it within a PS environment; if you so desire, feel free to translate it into the actual WinAPI calls, it will yield the same results when done correctly):

Code: Select all

System.IO.Directory.CreateDirectory(@"X:\SomeFolderWithTrailingSpaces ");
Note that the folder is created with a name without trailing space, because it is the last component in the path string.

The folder with a trailing space can be created by not letting it be the last component of the path string. Which can be achieved by adding a final trailing backslash to the path string:

Code: Select all

System.IO.Directory.CreateDirectory(@"X:\SomeFolderWithTrailingSpaces  \");
Then, you can create another sub-directory, also with a trailing space:

Code: Select all

System.IO.Directory.CreateDirectory(@"X:\SomeFolderWithTrailingSpaces  \OneMore \");
and so on...


Now, how about file names? A file name is usually the last component of a path string, so

Code: Select all

System.IO.File.Create(@"X:\SomeFileWithTrailingSpace.txt ");
wouldn't really work. Adding a backslash at the end of the file name obviously doesn't work here, either. Your claim seems to be true after all. But wait! You can exploit the data stream notation (which is supported at least by NTFS). Now, you could just some random data stream name like this:

Code: Select all

System.IO.File.Create(@"X:\SomeFileWithTrailingSpace.txt :SomeSecondaryDataStreamName");
But what if you want to write stuff into the normal default data stream (i.e., the "normal file content" stuff). Well just specify the default data stream instead of "SomeSecondaryDataStreamName":

Code: Select all

System.IO.File.Create(@"X:\SomeFileWithTrailingSpace.txt ::$DATA");
Et voila. This way you can create or open a file having a name with a trailing space by using nothing else than the Windows API.

I admit, it is a bit cheeky, but that doesn't mean it doesn't work.



Still, there is a fair agrument to be had about the difference between something that is possible to do vs. something that is (officially) supported. And since i expect several Windows components/programs having bad troubles dealing with such file/directory names, i absolutely do not recommend to anyone to ever utilize such bastardized file/directory names. At least not on Windows :)
NotNull
Senior Member
Senior Member
Posts: 298
Joined: 2019-11-25, 20:43 UTC
Location: NL

Re: No acces to network folder with name ending in a space

Post by *NotNull »

Try this from your client:

Code: Select all

CD "\\?\UNC\tsclient\c\$Folder\_Folder2\Folder number three\Folder Fourth\Folder Fifth \"
Post Reply