• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

find replace in c# with a certain character.

I have a issue with extracting some cells from c#.

When I open what I make in excel, the csv does some new lines or something and causes excel not to do CSV correctly.

I opened the file in wordpad and I found that there are some box characters [] < Like that but a full box.

So I did a find/replace and I was able to get rid of them and it opened in excel with correct formatting.

Does that [] mean it's a newline character?
 
Not likely, your best bet is to open it up with a Hex Editor and see what binary value is stored there, and translate that to a character to try and figure out what's getting put there instead.

Although, it's probably just easier to find the bug in your code 🙂
 
So, you have a text file that is comma separated values with some unwanted characters in there, is that right?

What you need to fix that is to open the file as a Textreader and read each line as a string. You can then do a simple string replace and write a new file from that.

int counter = 0;
string line;

// Read the file and display it line by line.
System.IO.StreamReader file = new System.IO.StreamReader("c:\\test.txt");
while ((line = file.ReadLine()) != null)
{
line.Replace("[]", "");
Console.WriteLine(line);
counter++;
}

file.Close();

// Suspend the screen.
Console.ReadLine();

Sample from Microsoft:
http://msdn.microsoft.com/en-u...y/aa287535(VS.71).aspx
 
Back
Top