We’re moving our forums to a new platform.

You can still browse and search existing topics, but you can no longer create new topics or post replies.

For questions, technical issues, or feature requests, please don’t hesitate to contact our support team at support@advancedinstaller.com.

Thank you for your understanding!

noisyfreak
Posts: 13
Joined: Mon Oct 28, 2013 3:05 pm

C# custom action, new line in property

Hi,
I want to put some text on a property, then use this property in a text file update. Datas in text are separated by a line break ( i can't change that ), but when i try to do the following in c# :
String str = "";
foreach (String line in lines)
{
str += line + "\n";
}
session["MACADDR"] = str;

inline datas appears in the file, like if the \n wasn't parsed by the text file update. Anyone have a solution ? :)

Regards.
Dan
Posts: 4530
Joined: Wed Apr 24, 2013 3:51 pm

Re: C# custom action, new line in property

Hello,

You may need to add a new line separator, CrLf (Carriage return–linefeed combination) for a text file.

So, can you please try to use the following and see if the behavior still persist:

Code: Select all

str += line + "\r\n"; 
Please let us know if that helped.

Best regards,
Dan
Dan Ghiorghita - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
noisyfreak
Posts: 13
Joined: Mon Oct 28, 2013 3:05 pm

Re: C# custom action, new line in property

Hi,
It's not working, \r\n is displayed in file.
I found a way by setting the line feed in the vbs then using in c# :
vbs :
Session.Property("LF")=vbLf
c# :
str += line + session["LF"]

Problem solved, thanks for answer.

Regards.
Dan
Posts: 4530
Joined: Wed Apr 24, 2013 3:51 pm

Re: C# custom action, new line in property

Hello,

Glad you got this working. Thank you for sharing this with us. Certainly this will help other users in the future.

If you have other questions, please let us know.

Best regards,
Dan
Dan Ghiorghita - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Building Installers”