why my coding some times can't locate the records?

hello I meet a issue based on the Virtual Table: file in Navision 2009,can I discuss with you? I am doing the code like:
(the ImportFile is the record based on File Record)
ImportFile.RESET;
ImportFile.SETRANGE(Date,WORKDATE);
ImportFile.SETRANGE(Path,ImportPath);
ImportFile.SETRANGE("Is a file",TRUE);

ImportFile.SETFILTER(Name,'%1','con_*.csv'); //Jerry Edited

//Jerry add this coding to pick the Sales/transfer Order from many input files,
//and then prepare for the function ImportData pick the correct data

IF ImportFile.FIND('-') THEN
REPEAT
FileName := ImportPath + ImportFile.Name; //Jerry

ImportData();

IF FILE.EXISTS(FileName) THEN
IF FILE.COPY(FileName,BackupPath + ImportFile.Name) THEN
Archived := TRUE;

IF Archived THEN
FILE.ERASE(FileName);
CLEAR(FileName);
CLEAR(Archived);

UNTIL ImportFile.NEXT =0;

but some time, some files can't be caught by these coding,I don't know why! Can you please share of some of your experience based on that? thanks !


Answers

  • txerifftxeriff Member Posts: 500
    Good morning, I think there's some "bug" in nav versions, I recommend you do this first to "initialise":
    
    //"initialise"
    CLEAR(FileRec);
    FileRec.SETCURRENTKEY(Path,"Is a file",Name);
    FileRec.SETRANGE(Path,'C:\temp\');
    IF FileRec.FINDFIRST THEN ;
    

    for me %1 didnt work, I sorted like:
    FileRec.SETRANGE(Path,'yourpath');
    FileRec.SETRANGE("Is a file",TRUE);
    FileRec.SETFILTER(Name,'order_response*'); //'%1*' doesnt work
    IF FileRec.FINDSET THEN REPEAT
    //do your thing
    UNTIL FileRec.NEXT=0;
    
  • RockWithNAVRockWithNAV Member Posts: 1,139
    Did you tried the way txeriff suggested?
  • jordi79jordi79 Member Posts: 275
    Hi,
    In my experience, the File virtual table sometimes does not work on mapped / network drives.
    I resorted to using the Dotnet.
    e.g.
    https://forum.mibuso.com/discussion/61335/read-client-files-in-folder
  • rxqrxqrxq_zydrxqrxqrxq_zyd Member Posts: 19
    thanks everybody finanlly I found I should not add the coding, ImportFile.SETRANGE(Date,WORKDATE); when I comment this sentence, it was working, it is closed, thanks
Sign In or Register to comment.