Add file path validation to Object Storage helper
Since checking if a file path is valid isn't trivial (checking for GetInvalidFileNameChars() is not sufficient) it would be nice if the storage helpers could validate the path itself or if there would be an separat helper.
Ping @Odonno
@ThisWillDoIt I am not sure I understand what you asked. You want to automatically check the parameter filePath when using ObjectStorage helper ?
Yes, that is correct.
For example currently a string including an '#' throws an exception while some other special chars are allowed. In most cases the filePath string will come from the app developer, who can try if those characters are valid or not.
But maybe there are scenarios where some kind of user input is part of the name. Which characters have to be stripped out? Which are okay? In addition to illegal characters I read somewhere that there are special file names not allowed on windows systems.
As I said I am not sure if this should be part of the storage helper it self or an separat helper, but it would be really nice to have an easy way to check if a given name/path is valid. Something like bool IsPathValid(string filePath);
I assume this method will be part of StorageFileHelper https://github.com/Microsoft/UWPCommunityToolkit/blob/dev/Microsoft.Toolkit.Uwp/Helpers/StorageFileHelper.cs
@ThisWillDoIt So, you only want a method to check if the path is valid or do you want it to be included in every method and throw an exception in case there is an illegal character ?
I am not really sure what the best approach would be, but I like the thing you started, since exceptions can already be handled. Maybe a hint in the documentation which exceptiones can occur by calling this method would be good.
The PR has been merged by @hermitdave. Thanks by the way.
@ThisWillDoIt I think it will fit your needs. If you have any troubles using the new methods or if you see something that goes wrong, I am sure we can see that together in the future.
Have fun!