所以,这是一个问题:我有几个文本框,我需要序列化它们。这就是我这样做的方式:
protected void Button1_Click1(object sender, EventArgs e)
{
Environment.CurrentDirectory = "d:/DZHosts/LocalUser/YoYoZ/LOL/Reports";
string[] s = new string[4];
FileStream fs = new FileStream(Environment.CurrentDirectory + "Report #" + i + ".rep", FileMode.OpenOrCreate, FileAccess.ReadWrite);
BinaryFormatter bf = new BinaryFormatter();
s[0] = TextBox1.Text;
s[1] = TextBox2.Text;
s[2] = TextBox3.Text;
s[3] = TextBox4.Text;
bf.Serialize(fs, s);
fs.Close();
i++;
Label1.ForeColor = Color.Green;
Label1.Text = "Complete!";
System.Threading.Thread.Sleep(3000);
Response.Redirect("http://LOL/Default.aspx");
}
但是当我按下写它说:
Access to the path 'C:\Windows\SysWOW64\inetsrv\Report #0.rep' is denied.
为什么它不尝试写入正确的目录?