Thursday, 23 August 2007

How to create a text file and write text into the file from Navision ?

// File1 is File object
// OutStreamObj is OutStream object

File1.CREATE( 'C:\Output.txt');
File1.CREATEOUTSTREAM(OutStreamObj);

OutStreamObj.WRITETEXT ('First line of text that you want to write to text file');
OutStreamObj.WRITETEXT ('This is not the second line of text to be outputed but to concatenate with the first line');

OutStreamObj.WRITETEXT(); // This command is to move to next line
OutStreamObj.WRITETEXT('Second line will start here') ;

File1.Close; // To end the writing and write out to the file.

7 comments:

Anonymous said...

thank you:)

Reka said...

It Helps me more to convert images to text. Thanks a Lot :)

Chris said...

This is so simple but has proved so helpful to me! Thank you!
Chris

Anonymous said...

After reading XML port instructions I wanted to shoot myself, then I saw this... thank you!

Anonymous said...

thank you....

Anonymous said...

Note - unless you are using the Classic Client, the file will be saved to the NAV Server directory unless you use a relative path. ie '\\LocalComputerName\C$\MyFile.txt'

Unknown said...

IF in created text file have no records then how to delete text files ???How to add code!!