|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
File Name ValidatorHi Folks,
do you know a file name validator ? I am reading a text file and I am creating new files in runtime. In some cases it is found string with invalid characters so. I have errors. I was able to avoid the problem with this character "/" Is there anything peace of code already ready for this ? Any help is appreciated. Thanks. Hi,
Use a regular expression. dim rFile as new regex([A-Z]:\\[^/:\*\?<>\|]+\.\w{2,6})|(\\{2}[^/:\*\?<>\|]+\.\w{2,6})") if rFile.isMatch(strFilename) then 'you have a valid file name end if http://search.msdn.microsoft.com/search/default.aspx?siteId=0&tab=0&query=regex Ken ------------------------- Show quoteHide quote "Brahm" wrote: > Hi Folks, > > do you know a file name validator ? > > I am reading a text file and I am creating new files in runtime. In some > cases it is found string with invalid characters so. I > have errors. > > I was able to avoid the problem with this character "/" > > Is there anything peace of code already ready for this ? > > Any help is appreciated. > > Thanks. > > > Brahm,
You can use the System.IO.Path class. Path.GetFileName will throw an exception if the filename contains invalid characters. Kerry Moorman Show quoteHide quote "Brahm" wrote: > Hi Folks, > > do you know a file name validator ? > > I am reading a text file and I am creating new files in runtime. In some > cases it is found string with invalid characters so. I > have errors. > > I was able to avoid the problem with this character "/" > > Is there anything peace of code already ready for this ? > > Any help is appreciated. > > Thanks. > > >
le nom 'vb6' n'est pas déclaré
Overload resolution failed All I'm looking for is a simple answer to a simple question DataGrid Control How do I use a class, when the class requires functions in the main form? Memory Manipulation Object-to-Relational Tool Error while file copying over network. Unmanaged C++ Void* Use HideDragon to Quick hide window, the best Boss key! |
|||||||||||||||||||||||