标题:求助:textbox保存后文本里面没有内容
只看楼主
Lymi
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2007-1-29
 问题点数:0 回复次数:0 
求助:textbox保存后文本里面没有内容
如题,保存后文本文档里面没有东西,新手请教高手们如何解决,我的代码如下
private void SaveFile_Click(object sender, EventArgs e)
        {
            Stream myStream;
            string fileName = "Untitled";
            SaveFileDialog saveFileDialog1 = new SaveFileDialog();
            
            saveFileDialog1.InitialDirectory = "c:\\";
            saveFileDialog1.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*";
            saveFileDialog1.FilterIndex = 2;
            saveFileDialog1.RestoreDirectory = true;

            if (saveFileDialog1.ShowDialog() == DialogResult.OK)
            {
                if ((myStream = saveFileDialog1.OpenFile()) != null)
                {
                    try
                    {
                        fileName = saveFileDialog1.FileName;
                        Stream stream = File.OpenWrite(fileName);
                        StreamWriter writer = new StreamWriter(fileName,false,Encoding.Default);
                        writer.Write(tbUserProgram.Text);
                        writer.Close();
                        stream.Close();
                        myStream.Close();
                    }
                    catch
                    { }

                }
            }

        }
搜索更多相关主题的帖子: textbox 文本 保存 
2008-04-17 15:16



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-209588-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.207541 second(s), 7 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved