Forum Discussion

mateenhussain's avatar
mateenhussain
Occasional Contributor
16 years ago

aqFile.WriteToTextFile is not writing new line characters to the file

Hi I'm trying to write to a text file using aqFile.WriteToTextFile. Here's the piece of code:




if(



 



aqFile.Create("A:\\dplogin.txt")!=0)

 


 



 




    Log.Warning("Unable to Create DPLogin.txt");

 


var str="abc\ncde\n";


if(!



 



aqFile.WriteToTextFile("A:\\dplogin.txt",str,22))

 


 



 



    Log.Warning("Unable to write to DPLogin.txt");

 



So I'm expecting something like

[Output]

abc

cde



[/Output]



But what I get is

[ActualOutput]

abccde



[/ActualOutput]



When I debug, str it has proper new line charecters as its value. Is this a bug or am I doing something wrong here.



Thanks,

Mateen

2 Replies

  • Tony_1's avatar
    Tony_1
    Occasional Contributor
    The line should read:

    str="abc" & Chr(13)& chr(10) & "cde" & Chr(13)& chr(10)





    note: Chr(13) = Carraige Return and Chr(10) = line feed.

    This is one way of doing it.



    Good luck!


  • In Windows the convention is to use a combination of \r\n (carriage return, newline) to represent the end of a line. Some text editors understand the \n on its own, but more basic editors like notepad require both characters.