NAV 2009 Download file

JohnConJohnCon Member Posts: 55
edited 2011-10-21 in NAV Three Tier
I am trying to use the new Download to move a tempfile created from the servicetier to the users workstation.
But I get "an I/O exception occured during the operation" error message.
The error occurs on the DOWNLOAD Line, the temp file is created succcessfully in the RTC and everything works fine in the classic client.
Can anyone explain the DOWNLOAD more, the help is not too informative.

IF ISSERVICETIER THEN BEGIN
ProfileFile.CREATETEMPFILE;
ExportTxtLines;
DOWNLOAD(ProfileFile.NAME, 'Download File','C:\',Text002,FileName);
END ELSE BEGIN
ProfileFile.CREATE(FileName);
ProfileFile.CLOSE;
ExportTxtLines;
END;

Comments

  • freddy.dkfreddy.dk Member, Microsoft Employee Posts: 360
    The problem is, that you cannot download an open file...
    Your next problem is that you cannot get the filename if the file isn't open.
    And I cannot remember when we clean those files up - but the safest way is using the following construct:

    // Get Temp FileName
    TempFile.CREATETEMPFILE;
    FileName := TempFile.NAME;
    TempFile.CLOSE;

    To get the filename - now create a new file in that filename., write to it, download it and delete it.
    You can find more on my blog in the following post:

    http://blogs.msdn.com/freddyk/archive/2008/11/04/transferring-data-to-from-com-automation-objects-and-webservices.aspx
    Freddy Kristiansen
    Group Program Manager, Client
    Microsoft Dynamics NAV
    http://blogs.msdn.com/freddyk

    The information in this post is provided "AS IS" with no warranties, and confers no rights. This post does not represent the thoughts, intentions, plans or strategies of my employer. It is solely my opinion.
  • JohnConJohnCon Member Posts: 55
    Thanks Freddy,
    That fixed it!!
  • MariaMaria Member Posts: 3
    i want to convert a report to pdf, for that i writ a code in the postdataitem in the report. the code is

    REPORT.SAVEASPDF(301, 'D:\Temp\default.pdf', Vendor);
    ToFile := STRSUBSTNO('Vendor No. %1.pdf', vendor."No.");
    PdfDownloaded := DOWNLOAD('D:\Temp\default.pdf', 'Save PDF As..', 'D:\','PDF file(*.pdf)|*.pdf', ToFile );

    when i run this report in the RTC an error occured "An I/O Exception occured during the operation". pls help me from this error....
    :-k
  • BeliasBelias Member Posts: 2,998
    SAVEASPDF actually runs the report. You don't have to call it in the onpost report of the report itself or, guess what? the report will run itself over and over! ;)
    try to create a new codeunit and move your code in its onrun trigger. In this way you can familiarize with the saveaspdf function easily.
    edit: you have to run the codeunit from the RTC, obviously (under an action in a page for example), because saveaspdf works only for rdlc reports :)
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
Sign In or Register to comment.