473,387 Members | 1,493 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

settings


Hello,

I am trying to add a \n to Settings in c#. But it dooesn't recognize it
as \n (string) How can I solve this? Thanks!

*** Sent via Developersdex http://www.developersdex.com ***
Aug 10 '08 #1
1 1204

"csharpula csharp" wrote:
>
Hello,

I am trying to add a \n to Settings in c#. But it dooesn't recognize it
as \n (string) How can I solve this? Thanks!

*** Sent via Developersdex http://www.developersdex.com ***
Hi,

If you are putting "\n" inside a string setting it appears to be transformed
to "\r\n ". This is because you are putting \n into an xml
which will end up looking like

<Namespace.Properties.Settings>
<setting name="Setting" serializeAs="String">
<value>
</value>
</setting>
</Namespace.Properties.Settings>

When you read from the xml you will end up with the part between <valueand
</valuewhich is correctly interpreted as "\r\n " ( a newline
and indentation )

On windows systems \r\n is the code for newline and even though \n may
sometimes be accepted as newline, it is not guaranteed to. The framework
will translate the incorrectly spelled newline character to a proper one,
which is why you get \r\n back even though you put \n in.

If you are creating an OS independent assembly, use Environment.Newline.
This will translate to \r\n or \n based on the OS the assembly is running on.
If you are streaming to/from non windows systems and need to determine if \n
should be used you may need a flag or store the value in a binary file.

--
Happy Coding!
Morten Wennevik [C# MVP]
Aug 11 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: GS | last post by:
Hi, There is reference about accessing settings file in VB.NET but nothing about C#. How do I read settings in application settings file with C#? Thanks, G
2
by: GS | last post by:
How do I use My.Settings equivalent in C#? Below is part of MSDN documentation about accessing settings file. I wrote C# console application using VS 2005 and .NET 2.0 and would like to use new...
10
by: Paul Cheetham | last post by:
Hi, I am developing an application that needs to store some machine-specific settings. The application is going to be published on the network in order to keep the clients on the latest version....
10
by: Chris Dunaway | last post by:
I have an .exe console project and a class library project as part of a solution. The .exe has an App.config file and I have used the Settings page to add some Application level settings. When...
2
by: MacKris | last post by:
Hi, I'm a chemist trying to use the python script GaussSum.py with gnuplot for creating dataplots, and need some help. Whenever I try to produce a plot from the GaussSum GUI I get the error sh:...
3
by: Jon Slaughter | last post by:
I wrote an app that needed to save settings such as colors, fonts, etc... after hours of trying to use ConfigurationManager and AppSettings along with a few other things I finally found that I...
5
by: Andy | last post by:
I need to write a VB.NET WinForms app. For this purpose I need to keep some settings of the application, like many other Windows applications do. The most obvious solution is to store settings in...
0
by: =?Utf-8?B?UmljayBHbG9z?= | last post by:
For some unknown reason (user error?), I cannot get a NameValueCollection to persist in the app.config file. Unlike other settings, I cannot get the String Collection Editor GUI to allow my to...
6
by: WT | last post by:
Hello, Using VS2005. I have an assembly library that can be called from a Web site asp.net application or from a winform application. From this library I need to retrieve a path using simply a...
5
by: Rainer Queck | last post by:
Hello NG, Is it possible to share the settings of an application with a class libreary? In my case I have a application and a set of different reports (home made) put into a class library. The...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.