Home » U++ Library support » FileSel&FileList, Path » How to determine the file type selected in a FileSel widget? [SOLVED]
How to determine the file type selected in a FileSel widget? [SOLVED] [message #2864] |
Fri, 28 April 2006 14:20 |
|
forlano
Messages: 1185 Registered: March 2006 Location: Italy
|
Senior Contributor |
|
|
Hello,
my application now needs to open a database (a text file with .txt or .csv extension) and process it according to its internal format that are two for each extension.
So I've 4 formats but only two extentions. This means that the only extension do not give me the possibility to remove the ambiguity.
For my purpose would be enough if I could simply get from the FilSel widget what type file the user selected. In fact I set:
fs.Type( "Files FIDE archive (text)", "*.txt")
.Type( "Files VEG (csv)", "*.csv;")
.Type( "Files FSI Italy (csv)", "*.csv")
.Type( "Files fixed lenght (text)", "*.txt")
.DefaultExt("txt");
Is there a way to return the string (or the index) of the .Type() the user select? I couldn't find an appropriate method while it is easy to get the extension:
String ext = ToLower( GetFileExt( filename ) ); // GetFileExt is in Core/Path.h
Thank you,
Luigi
[Updated on: Mon, 01 May 2006 13:18] by Moderator Report message to a moderator
|
|
|
Re: How to determine the file type selected in a FileSel widget? [message #2950 is a reply to message #2864] |
Mon, 01 May 2006 11:23 |
|
forlano
Messages: 1185 Registered: March 2006 Location: Italy
|
Senior Contributor |
|
|
forlano wrote on Fri, 28 April 2006 14:20 | Hello,
my application now needs to open a database (a text file with .txt or .csv extension) and process it according to its internal format that are two for each extension.
So I've 4 formats but only two extentions. This means that the only extension do not give me the possibility to remove the ambiguity.
For my purpose would be enough if I could simply get from the FilSel widget what type file the user selected. In fact I set:
fs.Type( "Files FIDE archive (text)", "*.txt")
.Type( "Files VEG (csv)", "*.csv;")
.Type( "Files FSI Italy (csv)", "*.csv")
.Type( "Files fixed lenght (text)", "*.txt")
.DefaultExt("txt");
Is there a way to return the string (or the index) of the .Type() the user select? I couldn't find an appropriate method while it is easy to get the extension:
String ext = ToLower( GetFileExt( filename ) ); // GetFileExt is in Core/Path.h
Thank you,
Luigi
|
I got the answer! Now that I found the solution after many experiments and investigation I can say that was quite obvious!
The FilSel dialog stores the above typefile information in a drop list named 'type'. So the index can be got by:
typeindex = fs.type.GetIndex();
The other element of the pair that arrived in the drop list, i.e. the extension, can be got by
ext = AsString(~fs.type());
Luigi
|
|
|
Goto Forum:
Current Time: Thu Apr 25 14:11:35 CEST 2024
Total time taken to generate the page: 0.03080 seconds
|