Options

Can't create txt file in client

catiamatos1991catiamatos1991 Member Posts: 158
edited 2018-09-21 in NAV Three Tier
HI everyone, I'm trying to create a txt file (nav 2016) with some data and for that I tried the "Hello World" example

So in the page action I added a button called TXT with the following code:

MESSAGE('WORD');

MyFile.CREATE( 'C:\teste.txt');
MyFile.CREATEOUTSTREAM(MyOutStream);

MyOutStream.WRITETEXT('Hello World!');

MyFile.CLOSE; // To end the writing and write out to the file.
MESSAGE('END WORD');

I read that nav stores the file in NAV server instead of client. How to download or save the file in the client ? I read about soem codeunits but I'm using Nav 2016 can i use that code? Below there's a example..

https://docs.microsoft.com/en-us/dynamics-nav/walkthrough--transferring-a-file-from-microsoft-dynamics-nav-server-to-the-client

how to use this in my context? Or are any other solutions ?

Best Answer

Answers

  • Options
    ftorneroftornero Member Posts: 522
    You can use the codeunit 419 (File Management), inside you have this function
    DownloadToFile(ServerFileName : Text;ClientFileName : Text)
    
  • Options
    catiamatos1991catiamatos1991 Member Posts: 158
    I'm getting this error,

    om7caxmsvxrb.png
  • Options
    AntoniomvallsAntoniomvalls Member Posts: 34
    Can u activate the debugger in order to see where the problem is?
    Giving thanks is always wellcome
  • Options
    catiamatos1991catiamatos1991 Member Posts: 158
    I got the error "System.IO.File.copy" failed because I don't have access to write in "C:\teste.txt", so I create a new folder and write to "C:\teste\teste.txt" and I could download the file ;)
  • Options
    Slawek_GuzekSlawek_Guzek Member Posts: 1,690
    The access to a root folder on any drive is restricted by default. You need Admin permissions on the system to create files in C:\ - that's why you cannot store anyting directly in C:\ folder.

    Slawek Guzek
    Dynamics NAV, MS SQL Server, Wherescape RED;
    PRINCE2 Practitioner - License GR657010572SG
    GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-03
  • Options
    catiamatos1991catiamatos1991 Member Posts: 158
    Thanks @Slawek_Guzek
  • Options
    krikikriki Member, Moderator Posts: 9,096
    [Topic moved from 'NAV/Navision Classic Client' forum to 'NAV Three Tier' forum]

    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


Sign In or Register to comment.