我的代码背后
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.IO;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
DirectoryInfo theFolder = new DirectoryInfo(@"C:\temp\Server_Attachments\6");
string Attachment = "";
foreach (FileInfo nextFile in theFolder.GetFiles())
{
Attachment += "<a href=\"C:\\temp\\Server_Attachments\\6\\blabla.xls\">" + nextFile.ToString() + "</a><br />";
div1.InnerHtml = Attachment;
}
}
protected void Attach_File(object sender, EventArgs e)
{
FileUpload1.SaveAs(@"C:\Server_Attachments\6");
}
}
我的 HTML 页面是这样的
<div id="div1" runat="server"></div>
<asp:Label ID="Label1" runat="server" Text=" Attach a file : "></asp:Label><br />
<asp:FileUpload ID="FileUpload1" runat="server" Font-Names="Tahoma" Font-Size="Small" />
<br />
<asp:Button ID="Button2" runat="server" Text=" Attach " Font-Names="Tahoma" Font- Size="Small" OnClick="Attach_File" />
超链接都没有,上传也没有工作:(
当我单击超链接时,什么也没有发生(尽管“将目标另存为”正在工作)。
当我尝试上传时,出现错误“访问路径 'C:\Server_Attachments\6' 被拒绝。”
这显然是一个安全问题。我检查了哪个帐户正在运行该程序,它是网络服务。
我该如何解决 ?我可以授予对 NETWORK SERVICE 的完全访问权限吗?它安全吗?