destroyhead
Programmer
Hi,
Here is my very simple program :
Code behind :
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" />
Neither the hyperlinks, neither the upload are working
- when I am clicking on the hyperlinks nothing is happening (although "Save target as" is working).
- when I am trying to upload, I have got the error "Access to the path 'C:\Server_Attachments\6' is denied."
On the server :
It is obviously a security issue. I have checked which account was running the program and it is NETWORK SERVICE.
On my laptop :
I have run my program on my laptop and still got the same error. It means that with the "pseudo" web server enhanced in VS2005, the same problem occurs ("Access to the path X is denied").
I have used System.Security.Principal.WindowsIdentity.GetCurrent().Name to check who was running the program and it is me. I have got administrator's rights on my workstation. I can copy a file in this folder on my own but not via ASP.NET.
Any idea how to fix this problem (options in Visual Studio?)?
Thanks very much for any help.
Olivier
Here is my very simple program :
Code behind :
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" />
Neither the hyperlinks, neither the upload are working
- when I am clicking on the hyperlinks nothing is happening (although "Save target as" is working).
- when I am trying to upload, I have got the error "Access to the path 'C:\Server_Attachments\6' is denied."
On the server :
It is obviously a security issue. I have checked which account was running the program and it is NETWORK SERVICE.
On my laptop :
I have run my program on my laptop and still got the same error. It means that with the "pseudo" web server enhanced in VS2005, the same problem occurs ("Access to the path X is denied").
I have used System.Security.Principal.WindowsIdentity.GetCurrent().Name to check who was running the program and it is me. I have got administrator's rights on my workstation. I can copy a file in this folder on my own but not via ASP.NET.
Any idea how to fix this problem (options in Visual Studio?)?
Thanks very much for any help.
Olivier