Can't Create text file using OutStream method on NAV 2013

chuan_214chuan_214 Member Posts: 4
edited 2014-05-09 in NAV Three Tier
Dear All,

I using the following method to create a txt file on my pc, they are:
Varible
==============================================
Name DataType Subtype
XMLTest XMLport Export Return Tab File
varXmlFile File
varOutputStream OutStream

Coding

varXmlFile.CREATE('D:\Test\Output.txt');
varXmlFile.CREATEOUTSTREAM(varOutputStream);
XMLPORT.EXPORT(XMLPORT::"Export Return Tab File", varOutputStream);
varXmlFile.CLOSE;


However, when i run the coding, it prompt such as error, please refer to image attach.

Thanks for your help.

Comments

  • Luc_VanDyckLuc_VanDyck Member, Moderator, Administrator Posts: 3,633
    The file will be created on the Service Tier server, not on your PC. Check if the directory "D:\Test" exists on the server.
    No support using PM or e-mail - Please use this forum. BC TechDays 2024: 13 & 14 June 2024, Antwerp (Belgium)
  • chuan_214chuan_214 Member Posts: 4
    The file will be created on the Service Tier server, not on your PC. Check if the directory "D:\Test" exists on the server.


    Then how i create that file at my PC? How i modify the coding?
  • thegunzothegunzo Member Posts: 274
    Hi

    You can use .net to write directly to your host.

    Look at http://www.dynamics.is/?p=1405 for examples.
    ________________________________
    Gunnar Gestsson
    Microsoft Certified IT Professional
    Dynamics NAV MVP
    http://www.dynamics.is
    http://Objects4NAV.com
  • Luc_VanDyckLuc_VanDyck Member, Moderator, Administrator Posts: 3,633
    Or use the functions in codeunit 419 to download the file to the client:
    txtTempFilename := cdu3TierMgt.ServerTempFileName('output','txt');
      filOutput.CREATE(txtTempFilename);
      filOutput.CREATEOUTSTREAM(lOutStream);
      XMLPORT.EXPORT(XMLPORT::"Your XMLPort", lOutStream);
      filOutput.CLOSE;
      cdu3TierMgt.DownloadToFile(txtTempFilename, 'D:\Test\output.txt');
    
    No support using PM or e-mail - Please use this forum. BC TechDays 2024: 13 & 14 June 2024, Antwerp (Belgium)
Sign In or Register to comment.