Click here to Skip to main content
15,888,968 members
Home / Discussions / C#
   

C#

 
AnswerRe: Help with datagridview ... Pin
Mycroft Holmes22-Dec-14 21:17
professionalMycroft Holmes22-Dec-14 21:17 
AnswerRe: Help with datagridview ... Pin
turbosupramk323-Dec-14 3:23
turbosupramk323-Dec-14 3:23 
GeneralRe: Help with datagridview ... Pin
Richard MacCutchan23-Dec-14 4:50
mveRichard MacCutchan23-Dec-14 4:50 
GeneralRe: Help with datagridview ... Pin
turbosupramk323-Dec-14 5:17
turbosupramk323-Dec-14 5:17 
GeneralRe: Help with datagridview ... Pin
Richard MacCutchan23-Dec-14 5:49
mveRichard MacCutchan23-Dec-14 5:49 
GeneralRe: Help with datagridview ... Pin
turbosupramk324-Dec-14 3:02
turbosupramk324-Dec-14 3:02 
GeneralRe: Help with datagridview ... Pin
Richard MacCutchan24-Dec-14 3:35
mveRichard MacCutchan24-Dec-14 3:35 
QuestionHow to save text from TextBox2 as UTF-16 (Unicode), and not as UTF-8 - C# Pin
Member 1041097221-Dec-14 20:29
Member 1041097221-Dec-14 20:29 
Hello guys!
How to save text from multiline TextBox2 as (.txt) UTF-16 (Unicode), and not as UTF-8.
This is my code that is not good:
C#
saveFileDialog1.Filter = "Text files (*.txt)|*.txt|All files (*.*)|*.*";
//Empty the FileName text box of the dialog
saveFileDialog1.FileName = String.Empty;
//Set default extension as .txt
saveFileDialog1.DefaultExt = ".txt";

//Open the dialog and determine which button was pressed
DialogResult result = saveFileDialog1.ShowDialog();

//If the user presses the Save button
if (result == DialogResult.OK)
{
    byte[] contents;
    System.Text.Encoding ascii = Encoding.Unicode;
    contents = ascii.GetBytes(textBox2.Text);

    using (Stream fs = (Stream)saveFileDialog1.OpenFile())
    {
        fs.Write(contents, 0, contents.Length);
        fs.Close();
        MessageBox.Show("File successfully saved!");
    }

}


I need a better solution. Thank you!

modified 22-Dec-14 4:22am.

QuestionRe: How to save text from TextBox2 as UTF-16 (Unicode), and not as UTF-8 - C# Pin
Richard MacCutchan21-Dec-14 22:29
mveRichard MacCutchan21-Dec-14 22:29 
AnswerRe: How to save text from TextBox2 as UTF-16 (Unicode), and not as UTF-8 - C# Pin
Member 1041097223-Dec-14 0:32
Member 1041097223-Dec-14 0:32 
GeneralRe: How to save text from TextBox2 as UTF-16 (Unicode), and not as UTF-8 - C# Pin
Richard MacCutchan23-Dec-14 1:41
mveRichard MacCutchan23-Dec-14 1:41 
AnswerRe: How to save text from TextBox2 as UTF-16 (Unicode), and not as UTF-8 - C# Pin
Rob Philpott22-Dec-14 0:58
Rob Philpott22-Dec-14 0:58 
QuestionEncoding enc = Encoding.GetEncoding("Windows-1251 && Windows-1250") Pin
Member 1041097221-Dec-14 9:38
Member 1041097221-Dec-14 9:38 
AnswerRe: Encoding enc = Encoding.GetEncoding("Windows-1251 && Windows-1250") PinPopular
Garth J Lancaster21-Dec-14 10:09
professionalGarth J Lancaster21-Dec-14 10:09 
GeneralRe: Encoding enc = Encoding.GetEncoding("Windows-1251 && Windows-1250") Pin
Member 1041097221-Dec-14 20:15
Member 1041097221-Dec-14 20:15 
AnswerRe: Encoding enc = Encoding.GetEncoding("Windows-1251 && Windows-1250") Pin
Amresh Bahadur Singh21-Dec-14 23:23
Amresh Bahadur Singh21-Dec-14 23:23 
Questionsending SMS using SMPP in C# Pin
Jassim Rahma20-Dec-14 22:59
Jassim Rahma20-Dec-14 22:59 
AnswerRe: sending SMS using SMPP in C# Pin
DamithSL20-Dec-14 23:25
professionalDamithSL20-Dec-14 23:25 
SuggestionRe: sending SMS using SMPP in C# Pin
Kornfeld Eliyahu Peter20-Dec-14 23:28
professionalKornfeld Eliyahu Peter20-Dec-14 23:28 
Suggestionimplementation suggesion for a customized list page Pin
NowYouSeeMe18-Dec-14 18:37
NowYouSeeMe18-Dec-14 18:37 
GeneralRe: implementation suggesion for a customized list page Pin
syed shanu18-Dec-14 19:16
mvasyed shanu18-Dec-14 19:16 
GeneralRe: implementation suggesion for a customized list page Pin
BillWoodruff19-Dec-14 3:57
professionalBillWoodruff19-Dec-14 3:57 
GeneralRe: implementation suggesion for a customized list page Pin
Amresh Bahadur Singh21-Dec-14 23:34
Amresh Bahadur Singh21-Dec-14 23:34 
QuestionCode Design - Event call, Catch exceptions or not? Pin
GerVenson18-Dec-14 12:38
professionalGerVenson18-Dec-14 12:38 
AnswerRe: Code Design - Event call, Catch exceptions or not? Pin
Eddy Vluggen19-Dec-14 7:14
professionalEddy Vluggen19-Dec-14 7:14 

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.