PDA

Click to See Complete Forum and Search --> : write to file... windows xp pro


pgrimes
Jan 7th, 2004, 03:32 PM
I'm having a problem with my asp.net app when I try to run it on windows xp pro. Below is the error I'm getting when I try to download a file and save it to the disk. I'm pretty sure the problem occurs because windows xp makes all the directories "read-only". The error is "Access to the path xxx is denied." The line it occurs on is below, in red.

Please help, this is urgent for me. Thanks.

Server Error in '/Caltrans_CPT_Previewer/XMLtoSVG' Application.
--------------------------------------------------------------------------------

Access to the path "C:\Caltrans_CPT_Previewer\XMLtoSVG\LAData\temp\tmp.xml" is denied.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.UnauthorizedAccessException: Access to the path "C:\Caltrans_CPT_Previewer\XMLtoSVG\LAData\temp\tmp.xml" is denied.

ASP.NET is not authorized to access the requested resource. Consider granting access rights to the resource to the ASP.NET request identity. ASP.NET has a base process identity (typically {MACHINE}\ASPNET on IIS 5 or Network Service on IIS 6) that is used if the application is not impersonating. If the application is impersonating via <identity impersonate="true"/>, the identity will be the anonymous user (typically IUSR_MACHINENAME) or the authenticated request user.

To grant ASP.NET write access to a file, right-click the file in Explorer, choose "Properties" and select the Security tab. Click "Add" to add the appropriate user or group. Highlight the ASP.NET account, and check the boxes for the desired access.

Source Error:


Line 40: xmlURL = "http://www.webhippo.com/temp/00-488.xml"
Line 41: End If
Line 42: myWebClient.DownloadFile(xmlURL, Request.ServerVariables("APPL_PHYSICAL_PATH") & "LAData\temp\tmp.xml")
Line 43: 'xmlURL = "http://www.webhippo.com/temp/00-488.xml"
Line 44: xmlDownloadDestination = Request.ServerVariables("APPL_PHYSICAL_PATH") & "LAData\temp\tmp.xml"

Edneeis
Jan 7th, 2004, 05:59 PM
Did you grant the ASP.NET account write permissions like it said?

pgrimes
Jan 7th, 2004, 07:18 PM
Ya, I even gave it full control. I've tried a bunch of things to try and remove read-only... I even downloaded a little app that's supposed to do it on windows xp... but, every time I uncheck read-only in the folder properties, it comes right back when I check it again. I've also tried removing the read-only attrb from the command line.

pvb
Jan 7th, 2004, 07:28 PM
It looks like you're trying to write to a directory underneath your website, probably have to tell IIS that it's writeable(is that a word?) anywho, try going into the IIS admin, right click on the directory you want to write to and make sure that the checkbox next to write is checked.

pgrimes
Jan 12th, 2004, 04:00 PM
Hi, thanks for the reply. I have already made sure that "Write" permissions are set in IIS.

For now, it isn't quite as urgent for me. I came down to LA and the problem isn't occuring on the server that my app will run on. It is however still occurring on my system and, I'd love to know why.

Feel free to post more suggestions.

Paul

pvb
Jan 12th, 2004, 07:57 PM
hmmm, that sux. I don't really know what's up, maybe try the bare minimum test to see if it's something else. I'm runnin WinXP Pro and ran this code and worked without setting any special permissions on the directory. Create the directory, C:\WebTest. Then run just this page in your project that's givin ya trouble:
<%@ Import Namespace="System" %>
<%@ Import Namespace="System.IO" %>
<script language="C#" runat="server">
protected void btnSave_Click(object sender, System.EventArgs e)
{
string filePath = @"c:\WebTest\Test.txt";
using (StreamWriter sw = new StreamWriter(filePath))
{
sw.WriteLine(DateTime.Now.ToString());
}
}
</script>
<html>
<body>
<form runat="server">
<asp:Button ID="btnSave" Runat="server"
OnClick="btnSave_Click" Text="Save"/>
</form>
</body>
</html> Might end up with the same problem, if not and that worked, make some temp directory in your web structure and see if that works.