System.UnauthorizedAccessException: Access to the path 'C:\Inetpub\wwwroot\HealthCard\NewsTextFiles\News.html' is denied.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access)
我正在使用 ckeditor 。编辑服务器上的文件并将文件保存在服务器上。它不在服务器上运行,但在我的本地机器上运行良好。
这是编辑和保存按钮的代码。
protected void btnSaveNews_Click(object sender, EventArgs e)
{
string str = Ckeditor.Text;
string str1 = Server.HtmlDecode(str);
//lblText.Text = str2;
FileStream fs = new FileStream(Server.MapPath("~/NewsTextFiles/News.html"), FileMode.Create , FileAccess.Write);
StreamWriter wr = new StreamWriter(fs);
wr.Write(str1);
wr.Dispose();
fs.Dispose();
pnleditor.Visible = false;
upleditor.Update();
upleditor.Visible = false;
}