Why does isfolder() returns true when the argument is a space character in Windows OS?

4 views (last 30 days)

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 30 Aug 2019
Windows treats " " as a relative path and then trims trailing spaces. Essentially it does something like this:
input = " ";
Since input is not absolute,
input = fl::filesystem::absolute(input)
which turns the input space into "C:/Users/temp/ "
Hence, Windows trims the trailing spaces which leaves "C:/Users/temp".
While this may seem unexpected, it is logically consistent with Windows behavior. If you replace " " with something like "folderWithTrailingSpace" then you will get the same behavior.

More Answers (0)

Categories

Find more on File Operations in Help Center and File Exchange

Tags

No tags entered yet.

Products


Release

R2018b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!