Click here to Skip to main content
15,895,799 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
int dataSize1 = subNumber.GetLength();
subtitleNewFile.Write(subNumber,dataSize1);
subtitleNewFile.Write("\r\n" ,2 ) ;		
subtitleNewFile.Close();


Output : b i l l i o n P e o p l e 2 8 s t a t e s

Thanks in advanced.
Posted

Start with the debugger.
Put a breakpoint on the line:
C#
subtitleNewFile.Write(subNumber,dataSize1);
And run your app. When it hits the breakpoint, start looking at exactly what is in the variables subNumber and dataSize1 - that should give you a clue as to exactly what values you are trying to write to the file. When you know that, you can start looking at exactly why the file content is not what you expected.

If the length is showing in the debugger as 24, and there are no extraneous spaces in the string, then you need to look at exactly how you are checking the file content, and then at the subtitleNewFile class to find out what you have doe to it when you created the stream.

We can't do any of that for you!
 
Share this answer
 
Possibly you have "Use Unicode Charater Set" in your project general configuration setting. This way a CString would hold 2-byte characters.
If you want to write single byte (ANSI) strings to your file either change your application character set or convert your CString content before writing to the file (see, for instance "Convert CString to const char*"[^].
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900