所以,這是一個問題: 我有幾個文本框,我需要序列化。 這就是我正在做的:一些奇怪的寫作文件
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.
爲什麼不嘗試寫入正確的目錄?
這段代碼從IIS中運行? – Rob4md
在任何情況下,使用\\而不是/ –