NAV 5.0 Operating system can not find file ... problem

ResenderResender Member Posts: 119
Hello all, I'm working on a project where I have to read several txt or csv files into the Nav 5.0 environment.
All the code works like a charm but the one problem I keep encountering is when I want to debug or run the codeunit a second time
But if I want to rerun it for a second time I get the error it cannot find the file from the previous run
Here is the code
bolProcessed := FALSE;
CLEAR(lrecFile);


lrecFile.RESET();
lrecFile.SETRANGE(Path,txtPathIn);
lrecFile.SETRANGE(lrecFile."Is a file",TRUE);
IF lrecFile.FIND('-') THEN
REPEAT
  txtPONummer := '';
  bolOKFile := TRUE;
  txtFileName := lrecFile.Name;
  logFile.CREATE(txtLogMap + 'Log_' + ShortFileName(txtFileName) + '_'
   + DELCHR(FORMAT(TODAY),'=','/\: ') + '_' +  DELCHR(FORMAT(TIME),'=','/\: ') + '.txt');
  logFile.CREATEOUTSTREAM(OutstreamObj);
  writeLog(txtFileName);
  writeLog('------------------------');
  IF bolOKFile THEN ProcessFile(lrecFile);
  logFile.CLOSE; //
UNTIL lrecFile.NEXT = 0;
CLEAR(lrecFile);

Comments

  • dansdans Member Posts: 148
    You need to change the Path to refresh the virtual table File.
    Microsoft Certified IT Professional for Microsoft Dynamics NAV

    Just a happy frood who knows where his towel is
  • ResenderResender Member Posts: 119
    Do I do this before or after I start reading files
  • SogSog Member Posts: 1,023
    Always before reading.
    |Pressing F1 is so much faster than opening your browser|
    |To-Increase|
  • ResenderResender Member Posts: 119
    Doesn't seem to works
  • SogSog Member Posts: 1,023
    lrecFile.RESET();
    lrecFile.SETRANGE(Path,ROOT);
    lrecfile.findset;//if your root doesn't contain any files or folders it will error, but seriously if your root doesn't have any files/folders, something else is wrong
    lrecFile.RESET();
    lrecFile.SETRANGE(Path,txtPathIn);
    lrecFile.SETRANGE(lrecFile."Is a file",TRUE);

    Does this work?
    |Pressing F1 is so much faster than opening your browser|
    |To-Increase|
Sign In or Register to comment.