Click here to Skip to main content
15,919,178 members
Home / Discussions / C#
   

C#

 
GeneralRe: changing the appearance of Tab in tab control Pin
KrunalC19-Dec-06 18:51
KrunalC19-Dec-06 18:51 
GeneralRe: changing the appearance of Tab in tab control Pin
Martin#19-Dec-06 20:03
Martin#19-Dec-06 20:03 
Question.net:Globalization and SQL:Collate Pin
enduro1x18-Dec-06 18:21
enduro1x18-Dec-06 18:21 
Questioncreating empty foler in set up and deployment Pin
justintimberlake18-Dec-06 17:31
justintimberlake18-Dec-06 17:31 
QuestionC# Code required Pin
sowmya_044418-Dec-06 17:23
sowmya_044418-Dec-06 17:23 
AnswerRe: C# Code required Pin
Guffa18-Dec-06 17:41
Guffa18-Dec-06 17:41 
GeneralRe: C# Code required Pin
karam chandrabose18-Dec-06 19:01
karam chandrabose18-Dec-06 19:01 
QuestionWriting to a Text File Pin
dsl/fahk18-Dec-06 16:35
dsl/fahk18-Dec-06 16:35 
I am new to codeproject, and relatively new to C#. Eventually i got bored of... non-saving uses... and decided i needed to save something. So i tried.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;

namespace FileMaker
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void btnCreate_Click(object sender, EventArgs e)
        {
            Stream myStream;
            SaveFileDialog saveFileDialog1 = new SaveFileDialog();

            saveFileDialog1.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*";
            saveFileDialog1.FilterIndex = 1;
            saveFileDialog1.RestoreDirectory = true;

            if (saveFileDialog1.ShowDialog() == DialogResult.OK)
            {
                if ((myStream = saveFileDialog1.OpenFile()) != null)
                {
                    StreamWriter wText = new StreamWriter(myStream);
                    wText.Write("CHEESE");

                    myStream.Close();
                }
            } 
        }
    }
}

It doesn't work. When i run the program and click on the button, and go through the save file dialog, a file does appear, but "CHEESE" does not appear in the text file. I cannot figure out why this doesn't work. So how do i fix this so that "CHEESE" appears in the file?

Thanks to anybody who helps!
AnswerRe: Writing to a Text File Pin
Luc Pattyn18-Dec-06 16:39
sitebuilderLuc Pattyn18-Dec-06 16:39 
GeneralRe: Writing to a Text File Pin
karam chandrabose18-Dec-06 18:36
karam chandrabose18-Dec-06 18:36 
QuestionUsing a Item Contained in a Combo Box to Activate a Textbox Pin
AvenueStuart18-Dec-06 15:36
AvenueStuart18-Dec-06 15:36 
AnswerRe: Using a Item Contained in a Combo Box to Activate a Textbox Pin
Luc Pattyn18-Dec-06 15:57
sitebuilderLuc Pattyn18-Dec-06 15:57 
AnswerRe: Using a Item Contained in a Combo Box to Activate a Textbox Pin
il_masacratore18-Dec-06 21:58
il_masacratore18-Dec-06 21:58 
QuestionC# indexers Pin
dabs18-Dec-06 13:23
dabs18-Dec-06 13:23 
AnswerRe: C# indexers Pin
MIHAI_MTZ18-Dec-06 20:48
MIHAI_MTZ18-Dec-06 20:48 
QuestionReflection error with XmlSerializer Pin
babbelfisken18-Dec-06 13:13
babbelfisken18-Dec-06 13:13 
QuestionQuerying Active Directory Pin
soup198318-Dec-06 11:50
soup198318-Dec-06 11:50 
AnswerRe: Querying Active Directory Pin
neonoid1619-Dec-06 7:14
neonoid1619-Dec-06 7:14 
GeneralRe: Querying Active Directory Pin
soup198319-Dec-06 12:58
soup198319-Dec-06 12:58 
GeneralRe: Querying Active Directory Pin
neonoid1620-Dec-06 8:06
neonoid1620-Dec-06 8:06 
QuestionI Need Your Suggestions Pin
kifahhk18-Dec-06 11:23
kifahhk18-Dec-06 11:23 
AnswerRe: I Need Your Suggestions Pin
led mike18-Dec-06 11:46
led mike18-Dec-06 11:46 
AnswerRe: I Need Your Suggestions Pin
Colin Angus Mackay18-Dec-06 12:54
Colin Angus Mackay18-Dec-06 12:54 
QuestionUndo Pin
netJP12L18-Dec-06 10:28
netJP12L18-Dec-06 10:28 
AnswerRe: Undo Pin
User 665818-Dec-06 10:35
User 665818-Dec-06 10:35 

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.