02-01-2008 02:17 PM
Here is a web page that supposedly offers a regex that will validate a file name input. I haven't tried this yet, but will soon. Check it out.
http://www.regexlib.com/REDetails.aspx?regexp_id=345
I hope this will save someone else the 30 minutes of Googling I spent looking for it.
Thanks to all who made this an educational conversation.
02-01-2008 02:24 PM
02-04-2008 09:34 AM
05-12-2008 01:06 PM
03-24-2009 07:48 PM
05-03-2010 12:41 AM - edited 05-03-2010 12:47 AM
Not sure where everybody sourced their filename illegal character rules. Heres some from MSDN (http://msdn.microsoft.com/en-us/library/aa365247(VS.85).aspx😞
CON, PRN, AUX, NUL, COM1, COM2, COM3, COM4, COM5, COM6, COM7, COM8, COM9, LPT1, LPT2, LPT3, LPT4, LPT5, LPT6, LPT7, LPT8, and LPT9. Also avoid these names followed immediately by an extension; for example, NUL.txt is not recommended. For more information, see Namespaces.
** The code kindly posted by Rob F does not deal with file or directory names which end with a space or period.
05-03-2010 01:04 AM
Check if path ends in space or period by reversing string (converted to string) and checking if first character (index 0) matches. Modified code as follows:
Check for path ending in space and/or period. It is illegal and generates an error in Windows when you try to create a file/folder.
05-03-2010 01:46 AM
Another option for the space or period at the end of a string is using a regular expression:
Also, here's an old example which shows this with a bubble similar in style to that of Windows Explorer (reply 11).
03-15-2011 03:30 PM
If you are on 8.6 or newer there is a VI in the vi.lib that I think does what you need. Look in vi.lib\Utility\libraryn.llb\Is Name Multiplatform.vi.
Looking at the source I see a whole lot of code handling other operating systems. It also gives a suggestion file name that does work is valid.
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
17 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord
05-15-2012 09:05 AM
I have found that LabVIEW's "Open/Create/Replace File Function" cannot handle valid characters in a file path, such as single quotes ('), whereas the TDMS Open function handles this properly.
Does anyone have any advice for how to use the single quote (') for LabVIEW file paths other than TDMS?
I have attached the test cases which illustrate the problem.