Results 1 to 2 of 2

Thread: [RESOLVED] Problem displaying escape characters from a resource file string

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2006
    Posts
    4

    Resolved [RESOLVED] Problem displaying escape characters from a resource file string

    Hi folks,

    I've been developing a small console application and I'm trying to move all of my error message strings to a central resource file.

    This is an example of some code before using the resource file. Notice how I use the \n character to insert a new line.

    Code:
    Console.WriteLine ("Directory does not exist!\nUpdate Cancelled.");
    dsiplays...
    Directory does not exist!
    Update Cancelled.


    My problem is this, when I move this string to a resource file, the value does not interpret the \n character as a New Line character.

    Code:
    Console.WriteLine(MyResourceFile.MyResourceString);
    displays...
    Directory does not exist!\nUpdate Cancelled.

    Can anyone tell me how I can get the resource file string to be interpreted as including the new line character.

    Thanks in advance,

  2. #2

    Thread Starter
    New Member
    Join Date
    Apr 2006
    Posts
    4

    Re: Problem displaying escape characters from a resource file string

    I found an article on this topic here.

    When using a resource file, the '\n' is interpeted as '\\n', which means we need to use the replace function to change the \\n back to \n before displaying.

    You can also type the NewLine characters directly in to the Resource File by using the Shift+Enter combo, like you would with MS Word.

    We did have some limited success sub-classing the ResourceManager class to modify the GetString function, but each time the project is recompiled the Resource.designer.cs code appears to be overwritten by the resgen utility(?!?). Will need to investigate further to see if we can get this to work?!
    Last edited by Krispy.; Oct 20th, 2006 at 03:39 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width