Click here to Skip to main content
15,905,028 members
Home / Discussions / C#
   

C#

 
GeneralRe: DataGrid Pin
Charlie Williams6-Jun-04 14:42
Charlie Williams6-Jun-04 14:42 
GeneralRe: DataGrid Pin
myNameIsRon6-Jun-04 15:09
myNameIsRon6-Jun-04 15:09 
GeneralRe: DataGrid Pin
Dave Kreskowiak7-Jun-04 6:38
mveDave Kreskowiak7-Jun-04 6:38 
GeneralRe: DataGrid Pin
myNameIsRon8-Jun-04 11:22
myNameIsRon8-Jun-04 11:22 
GeneralSave a string in text file Pin
zlaty6-Jun-04 8:56
zlaty6-Jun-04 8:56 
GeneralRe: Save a string in text file Pin
Mazdak6-Jun-04 9:13
Mazdak6-Jun-04 9:13 
GeneralRe: Save a string in text file Pin
zlaty6-Jun-04 9:43
zlaty6-Jun-04 9:43 
GeneralRe: Save a string in text file Pin
Heath Stewart6-Jun-04 13:46
protectorHeath Stewart6-Jun-04 13:46 
What Mazdak said isn't completely right. In order to get the bytes for your string, you need to use an Encoding class like Encoding.ASCII and call the GetBytes(string) method to get the byte[] array ("buffer") that you write to a FileStream. If you use a TextWriter derivative, like the StreamWriter someone else mentioned, it does all this for you automatically. Just make sure to specify which encoding you want to use in the constructor:
using (StreamWriter writer = new StreamWriter("file.txt", true,
  Encoding.UTF8))
  writer.WriteLine("This is a single line.");
}
The using statement here makes sure that the StreamWriter is closed and all unmanaged resources (like file handles) are freed when the block of code is done - even in case of an exception.

 

Microsoft MVP, Visual C#
My Articles
GeneralRe: Save a string in text file Pin
Heath Stewart6-Jun-04 13:47
protectorHeath Stewart6-Jun-04 13:47 
GeneralRe: Save a string in text file Pin
Peff6-Jun-04 10:20
Peff6-Jun-04 10:20 
GeneralRe: Save a string in text file Pin
zlaty6-Jun-04 10:34
zlaty6-Jun-04 10:34 
GeneralRe: Save a string in text file Pin
Heath Stewart6-Jun-04 13:43
protectorHeath Stewart6-Jun-04 13:43 
GeneralRe: Save a string in text file Pin
zlaty7-Jun-04 4:21
zlaty7-Jun-04 4:21 
GeneralRe: Table Size Selector Control Pin
Heath Stewart6-Jun-04 13:48
protectorHeath Stewart6-Jun-04 13:48 
GeneralMicrosoft.ApplicationBlocks.ExceptionManagement Pin
Member 11509016-Jun-04 6:22
Member 11509016-Jun-04 6:22 
GeneralRe: Microsoft.ApplicationBlocks.ExceptionManagement Pin
Charlie Williams6-Jun-04 8:31
Charlie Williams6-Jun-04 8:31 
QuestionHow can i get the index of a doubleclicked item in the listbox? Pin
yipan6-Jun-04 5:24
yipan6-Jun-04 5:24 
AnswerRe: How can i get the index of a doubleclicked item in the listbox? Pin
Stefan Troschuetz6-Jun-04 6:32
Stefan Troschuetz6-Jun-04 6:32 
GeneralTextbox/Comobox in MenuItem Pin
DennisMetz6-Jun-04 5:18
DennisMetz6-Jun-04 5:18 
Generalsaving a graphic context Pin
cristina_tudor5-Jun-04 22:18
cristina_tudor5-Jun-04 22:18 
GeneralRe: saving a graphic context Pin
leppie5-Jun-04 23:52
leppie5-Jun-04 23:52 
GeneralRe: saving a graphic context Pin
cristina_tudor6-Jun-04 0:17
cristina_tudor6-Jun-04 0:17 
GeneralRe: saving a graphic context Pin
Heath Stewart6-Jun-04 13:33
protectorHeath Stewart6-Jun-04 13:33 
GeneralDifference between Directory and DirectoryInfo Pin
?!?5-Jun-04 19:37
?!?5-Jun-04 19:37 
GeneralRe: Difference between Directory and DirectoryInfo Pin
Stefan Troschuetz5-Jun-04 20:57
Stefan Troschuetz5-Jun-04 20:57 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.