Deleting External File within Navision

SbhatSbhat Member Posts: 301
edited 2005-05-23 in Navision Attain
Hi Folks,

Does anyone know how to delete a external file within Navision. Everytime i run a dataport to export records and if the file already exist on my C: drive system gives a message 'File already exist. Do you want to overwrite'. I want to delete the file evertime i run the dataport.

Has anyone done this kind of modification. Any help is really appreciated.

Thanks

Best regards
Suresh.

Comments

  • PrebenRasmussenPrebenRasmussen Member Posts: 137
    IF EXISTS(CurrDataport.FILENAME) THEN
      ERASE(CurrDataport.FILENAME);
    
    Remark: Erase has an optional return value.
  • SbhatSbhat Member Posts: 301
    Thanks Preben, that worked like a charm.

    Best regards
    Suresh.
  • FabriceGFabriceG Member Posts: 12
    Create a codeunit
    First step: delete the existing file
    example: ERASE('c:\Testfile.txt');
    Second step: Launch the dataport
    example: dataport.run(50000)
  • nelsonnelson Member Posts: 107
    It's much easier and logical to do:
    CurrFile.QUERYREPLACE(FALSE);
    
    in OnInitDataport or OnPreDataport.
    Check out: http://www.mbsonline.org/forum/topic.asp?TOPIC_ID=9660
    Nelson Alberto
  • eromeineromein Member Posts: 589
    Nice one Nelson!

    This way the user is "notified" of a possible mistake!
    "Real programmers don't comment their code.
    If it was hard to write, it should be hard to understand."
  • NavmanNavman Member Posts: 1
    hey nelson,

    really nice code - works well. But it doesn´t work if I call it via Navision batch. At least in my Navision 3.7.
    The batch ist stopped and is waiting for input (overwrite? Y/N). Just like your code ist ignored.
    Any ideas?!
Sign In or Register to comment.