Hello,
I am trying to retrieve the TXT files using the File record. In the directory I have this files :
Sales.txt
Purchase.txt
_Sales.txt
_Purchase.txt
But I want to exclude those TXT files with "_" in the begining of the filename. So I have put in my code this :
rFile.RESET;
rFile.SETRANGE(Path, 'c:\');
rFile.SETRANGE("Is a File", TRUE);
rFile.SETFILTER(Name, '%1|%2', '*.txt', '<>_*.txt');
IF rFile.FIND('-') THEN REPEAT
MESSAGE(rFile.Name);
UNTIL rFile.NEXT = 0;
But somehow in the results, it still includes the files with "_" in the beginning of their filenames. ](*,)
Please hand me some suggestions. Thanks in advance.
Navision noob....
Comments
http://www.mibuso.com/forum/viewtopic.php?f=5&t=18962&hilit=wildcard
"Never memorize what you can easily find in a book".....Or Mibuso
My Blog
Try this: Regards,
Reijer
Object Manager
I tried your inputs but still with the same results... Still includes the files with "_" in the begining of their filenames.
Microsoft Dynamics NAV Developer since 1997
MSDynamics.de - German Microsoft Dynamics Community - member of [clip]
It works ok in my client.
Object Manager
I think you are using Sql db.
@Timo
Many Thanks for the suggestion. I know I can do it that way with the help of function COPYSTR. But the scenario is much more complicated actually. I have a setup wherein user can put what are the filenames to include and exclude in the output. So I cannot put my code that way.
My code is like this :
Any suggestion will be greatly appreciated. Thanks again in advance.
I thought that the problem was lying in the fact that you were using a `|`-sign instead of a `&`-sign.
But the problem is that the filter `<>_*` is not working with a native db.
Object Manager
I have test your codes in SQL db and its working.... but too bad I am using Native db .
Anyways... I am trying to do it also in sql. But my code now is like the codes In my last post. How can I apply your code in that codes? Thanks again in advance.
I cannot understand what this code should do...
Are you applying a filter like this? (this is an example). In this case i expect to retrieve every file in the folder...the name of a file will ever be different from a.txt or from b.txt... :-k
if so, do you know that "|" is "OR"? and "&" is "AND"
or maybe i'm missing something... :-k :-k :-k :-k :-k
"Never memorize what you can easily find in a book".....Or Mibuso
My Blog
Yeah I think my bad coding and analysis also... :oops:
I didnt consider the operator..
Belias and reijermolenaar are right. Operator should be '&' not '|'.
Anyways what I want to do is to retrieve all the files '*.txt' in the directory but exclude those files that are in the variables ExcludeFile1 - 5 (from my code).
Object Manager
Thanks for the inputs. I already manage to do it, as the way you did it.