Determining if a string is a valid filename for system
-
How can you determine if a string is in fact a valid filename for the system I am on? What i want to do is have a textbox where a user can edit a string, and then opening a save dialog where the text from the textbox shall be proposed as the name of the file, provided it is a valid filename. Otherwise I want to propose a standard default filename for him/her. any ideas? I tried to use the path class and call one of it's static members since the documentation seems to say that all static members of Path check this for you. This does not seem to be the case however since I do not get an exception from for example Path.IsPathRooted(path), but when calling the showdialog() for the SaveFileDialog I get the argumentexception... /Bjørn
-
How can you determine if a string is in fact a valid filename for the system I am on? What i want to do is have a textbox where a user can edit a string, and then opening a save dialog where the text from the textbox shall be proposed as the name of the file, provided it is a valid filename. Otherwise I want to propose a standard default filename for him/her. any ideas? I tried to use the path class and call one of it's static members since the documentation seems to say that all static members of Path check this for you. This does not seem to be the case however since I do not get an exception from for example Path.IsPathRooted(path), but when calling the showdialog() for the SaveFileDialog I get the argumentexception... /Bjørn
Path will be valid as long as it has the valid characters, which u can check for. xacc-ide 0.0.15 now with C#, MSIL, C, XML, ASP.NET, Nemerle, MyXaml and HLSL coloring - Screenshots