Beloew是我的代码,我想保存一些信息用户键保存到文件中,我在调试后如何继续遇到Ioexception错误并单击保存按钮..请亲切地说。我猜这与文件夹有关,但绝对没有想法..当选择保存按钮时出现IoException错误
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 ASSISNMENTTT
{
public partial class Registeration : Form
{
public Registeration()
{
InitializeComponent();
}
private void Btn_Save_Click(object sender, EventArgs e)
{
// This is the button labeled "Save" in the program.
//
File.WriteAllText("C:\\demo.txt", Tb_Admin.Text);
File.WriteAllText("C:\\demo.txt", Tb_Name.Text);
File.WriteAllText("C:\\demo.txt", Tb_Gender.Text);
}
}
}
你可以给堆栈跟踪和异常消息吗? – 2010-12-14 01:50:39
尝试将文件保存到其他位置,例如在用户配置文件中。您可能没有写入权限C:\ – shf301 2010-12-14 02:08:57
正如有人在我删除的答案中指出的那样 - 如果存在权限问题而不是IOException,则会得到UnauthorizedAccessException。我的记忆一定要去! – 2010-12-14 02:14:01