It looks like you're new here. Sign in or register to get started.
Magicpath() : Text[1024] EXIT('<TEMP>'); // MAGIC PATH makes sure we don't get a prompt
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. } }
Comments
http://mibuso.com/blogs/mohana/2011/02/20/file-export-in-rtc-with-%e2%80%9ccommon-dialog-management%e2%80%9d/
-Mohana
http://mohana-dynamicsnav.blogspot.in/
https://www.facebook.com/MohanaDynamicsNav
-Mohana
http://mohana-dynamicsnav.blogspot.in/
https://www.facebook.com/MohanaDynamicsNav
This is my code:
IF NOT DOWNLOAD(FileName,'','h:','',ToFileName) THEN
ERROR('No');
Where:
Filename (string) = RBMgt.EnvironFileName('','txt');
ToFileName (string) = 'H:\Test.txt'
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