05-15-2012 09:20 AM
Nevermind!
TDMS Open handles "/" in a filesystem agnostic manner, whereas O/C/R File is filesystem dependent so it requires "\" on Windows.
02-19-2014 04:07 AM
I use a very simple and OS-independent method: create a temporary file with that name, if it succeeds then the file name is valid. Is it a bad idea?
02-19-2014 07:50 AM
@Snamprogetti wrote:
I use a very simple and OS-independent method: create a temporary file with that name, if it succeeds then the file name is valid. Is it a bad idea?
I wouldn't call it a bad idea, but as I said there is a built in function like I mentioned.
vi.lib\Utility\libraryn.llb\Is Name Multiplatform.vi
Your method could be wasting time because it sounds like you will be making the file twice.
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
17 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord
02-19-2014 08:10 AM
That built-in function is a bit complicated, especially if you only need to check on current OS, yet it doesn't get every possible problem. It doesn't check maximum name length for example, and there may be other cases they didn't think of.
Testing is safer, and i'm not making the file twice, at least not now; if i wanted to create the real file right after the check, i wouldn't do the check... i'd just create it and handle errors
02-19-2014 09:00 AM
That's now how I interpreted your post.
create a temporary file with that name
To me that sounds like you are making a file in something like %temp%\Example File Name.ini
Then if it succeeds you know the file name is valid, and would then make that file in the correct location that you originally wanted like C:\Program Data\My Program\Example File Name.ini
In this case you wouldn't be properly checking for the character size limit either.
Also using the VI I mentioned it will provide a valid file name that will work. So if you tried to make your file and it failed how would you handle it? If you use the function I linked you won't need to worry about it because you know the file name it returns is valid. Sure you have the 255 character limit (in Windows) to worry about but you at least have a good name to use.
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
17 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord
08-29-2023 07:10 PM
9 years later...but this was the first thing that showed up in a google search.
"Is Name Multiplatform" doesn't actually catch everything. One failure case: trailing spaces on Windows. Or even a file name that's only spaces. Windows won't allow this, but "Is Name Multiplatform" won't object.
08-30-2023 03:20 AM
Just like 9 years ago...
08-30-2023 03:38 AM - edited 08-30-2023 03:40 AM
Hi,
long time ago I had to prevent users from using illegal chars in filenames when they were ask to input a filename. That's what I used:
Use case: inside of a ValueChange event of the filename string input (string control set to update while typing)…