DOWNLOAD function

clemboclembo Member Posts: 122
edited 2012-06-22 in NAV Three Tier
I have this code:

IF NOT DOWNLOAD(FileName,'','c:\Temp','',ToFileName) THEN
ERROR('Error..');

Why Nav ask me save or open with dialog window?
How I can to skip and save it without ask me before?

Comments

  • clemboclembo Member Posts: 122
    But my problem is that I DON'T want common dialog...
  • mohana_cse06mohana_cse06 Member Posts: 5,503
    Then simply skip that part and give fixed path in FileName2..
  • koubekkoubek Member Posts: 84
    You should you functions of the CU 419. There is one that can help you to solve the problem - "Magicpath"
    Magicpath() : Text[1024]
    EXIT('<TEMP>');   // MAGIC PATH makes sure we don't get a prompt
    
    The description says it all. Than you can handle with your file as you want (move it/copy it etc.)
  • clemboclembo Member Posts: 122
    koubek, can you write sample?

    This is my code:

    IF NOT DOWNLOAD(FileName,'','h:','',ToFileName) THEN
    ERROR('No');

    Where:
    Filename (string) = RBMgt.EnvironFileName('','txt');
    ToFileName (string) = 'H:\Test.txt'
  • koubekkoubek Member Posts: 84
    This is a simple demonstration. Focuse on the function "RunDemo()".
    OBJECT Page 50009 Download File Demo
    {
      OBJECT-PROPERTIES
      {
        Date=18/06/12;
        Time=22:53:37;
        Modified=Yes;
        Version List=JVN,FILE,DOWNLOAD;
      }
      PROPERTIES
      {
        CaptionML=ENU=Download File Demo;
        SaveValues=Yes;
        OnOpenPage=BEGIN
                     IF (SrcFileName = '') THEN
                       SrcFileName := 'C:\Temp\MySourceFile.txt';
    
                     IF (DestFileName = '') THEN
                       DestFileName := 'C:\Temp\MyDestinationFile.txt';
                   END;
    
        ActionList=ACTIONS
        {
          { 1100225000;  ;ActionContainer;
                          CaptionML=ENU=Demo;
                          ActionContainerType=NewDocumentItems }
          { 1100225001;1 ;Action    ;
                          Name=<Action1100225001>;
                          CaptionML=ENU=Run Demo;
                          Promoted=Yes;
                          PromotedIsBig=Yes;
                          PromotedCategory=Process;
                          OnAction=BEGIN
                                     RunDemo;
                                   END;
                                    }
        }
      }
      CONTROLS
      {
        { 1100225002;;Container;
                    CaptionML=ENU=Download Demo Data;
                    ContainerType=ContentArea }
    
        { 1100225005;1;Group  ;
                    CaptionML=ENU=File Names;
                    GroupType=Group }
    
        { 1100225003;2;Field  ;
                    CaptionML=ENU=Source File;
                    SourceExpr=SrcFileName }
    
        { 1100225004;2;Field  ;
                    CaptionML=ENU=Target File;
                    SourceExpr=DestFileName }
    
      }
      CODE
      {
        VAR
          FileMgt@1100225002 : Codeunit 419;
          SrcFileName@1100225000 : Text[1024];
          DestFileName@1100225001 : Text[1024];
          Text001@1100225003 : TextConst 'ENU=You have not define any of parameters!';
          Text002@1100225004 : TextConst 'ENU=The file has been downloaded';
          Text003@1100225005 : TextConst 'ENU=Destionation file already exists! Delete it first!';
    
        PROCEDURE RunDemo@1100225001();
        VAR
          LocalTempFile@1100225000 : Text[1024];
        BEGIN
          IF (SrcFileName = '') OR (DestFileName = '') THEN
            ERROR(Text001);
    
          IF (EXISTS(DestFileName)) THEN
            ERROR(Text003);
    
          LocalTempFile := FileMgt.DownloadTempFile(SrcFileName);
          RENAME(LocalTempFile,DestFileName);
    
          IF GUIALLOWED THEN
            MESSAGE(Text002);
        END;
    
        BEGIN
        END.
      }
    }
    
  • thegunzothegunzo Member Posts: 274
    Hi Koubek

    You will have to use a client base RENAME function. The one in your example is server based.

    I use the automation object "'Windows Script Host Object Model'.FileSystemObject"

    A codeunit with the automation based filesystem function can be downloaded from my blog http://www.dynamics.is/?p=218
    ________________________________
    Gunnar Gestsson
    Microsoft Certified IT Professional
    Dynamics NAV MVP
    http://www.dynamics.is
    http://Objects4NAV.com
Sign In or Register to comment.