code unit

Write a codeunit which will create a text file by name customer.txt in C drive and write customer code and names in it

CLEAR(MyFile);

MyFile.TEXTMODE(TRUE);

MyFile.WRITEMODE(TRUE);

MyFile.CREATE(‘c:\MyNewFolder\Customer.txt’);

MyFile.WRITE(“No.”);

MyFile.CLOSE();

i have written this code but i am not customer nos in text file only getting text like field name No.

Go to properties of Codeunit and select Table no as 18

i changed in properties also but not getting

Look at this link

http://msdn.microsoft.com/en-us/library/hh167550(v=nav.70).aspx

Actually i am getting no.of characters writing in text file but not able to write customer records in text file.

please help me

You need to get the Customer Record and loop through all the records

CLEAR(MyFile);
MyFile.TEXTMODE(TRUE);
MyFile.WRITEMODE(TRUE);
MyFile.CREATE(‘c:\Customer.txt’);
IF Cust.FINDSET THEN
REPEAT
MyFile.WRITE(Cust.“No.”);
UNTIL Cust.NEXT = 0;
MyFile.CLOSE();