Delete files in a directory

jlettjlett Member Posts: 9
edited 2004-10-24 in Navision Attain
In a dataport, I want first to verify if there are files in a directory and after delete them.


REPERTOIRE.SETFILTER(REPERTOIRE.path,'\\Srvpv2\commun\6_SAM\Fichiers tests\2004_10_22\');
REPERTOIRE.SETFILTER(REPERTOIRE.name,'*.txt');
IF REPERTOIRE.FIND('-') THEN
REPEAT
erase(REPERTOIRE.path+REPERTOIRE.name);
UNTIL REPERTOIRE.NEXT=0;

:D

Comments

  • jhoekjhoek Member Posts: 216
    To find out which files exist is a certain folder, you can define a variable of type Record, subtype File, and place a filter on the Path field. Using a normal if Find('-') then repeat [...] until Next = 0 construct, you can then loop through the files, using FILE.ERASE to delete the ones you want to get rid of.
    Kind regards,

    Jan Hoek
    Product Developer
    Mprise Products B.V.
Sign In or Register to comment.