请高手帮看看 为什么程序会死掉~ 并且数据写不进文本

afeny 2008-03-13 03:16:21
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 WindowsApplication2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)
{

string x;
x = System.Windows.Forms.Application.StartupPath;

if(false == System.IO.File.Exists(x + "/map/0.map"))
{
MessageBox.Show("请安装在正确目录");
}

FileStream ftp = new FileStream("ftp.ini", FileMode.Create, FileAccess.Write);
StreamWriter sw = new StreamWriter(ftp);
sw.WriteLine(x + "[Server]", "Servercount", "1");
sw.WriteLine(x + "server1caption", textBox1.Text);
sw.WriteLine(x + "server1name", textBox1.Text);
sw.Flush();

FileStream mir = new FileStream("mir.ini", FileMode.Create, FileAccess.Write);
StreamWriter sw1 = new StreamWriter(mir);
sw1.WriteLine("[setup]", "fontname", FontStyle.Bold);
sw1.WriteLine("SeverAddr", textBox2.Text);
sw1.Flush();

ftp.Close();
mir.Close();
sw.Close();
sw1.Close();

}
}
}
...全文
65 4 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
afeny 2008-03-13
  • 打赏
  • 举报
回复
恩` ~ 3楼的回答是正确的~ 不过在你告诉我答案之前 我已经找到不 但是还是给你了20分 谢谢你哦~
xxoo2007 2008-03-13
  • 打赏
  • 举报
回复
//先关闭缓冲,在关闭文件试试.我测试的时候这句是报错了."无法访问已关闭的文件。 "
sw.Close();
sw1.Close();

ftp.Close();
mir.Close();
priwilliam 2008-03-13
  • 打赏
  • 举报
回复
请lz换个数据量小的文本看看
b哈利路亚d 2008-03-13
  • 打赏
  • 举报
回复
...没看出来,别的地方没用过什么东西吧,特别是多线程什么的

111,097

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • AIGC Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧