Results 1 to 6 of 6

Thread: write to file... windows xp pro

  1. #1

    Thread Starter
    Hyperactive Member pgrimes's Avatar
    Join Date
    Aug 2001
    Location
    sacramento
    Posts
    342

    write to file... windows xp pro

    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"

  2. #2
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    Did you grant the ASP.NET account write permissions like it said?

  3. #3

    Thread Starter
    Hyperactive Member pgrimes's Avatar
    Join Date
    Aug 2001
    Location
    sacramento
    Posts
    342
    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.

  4. #4
    Hyperactive Member
    Join Date
    Aug 2002
    Location
    Fort Collins, CO
    Posts
    366
    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.

  5. #5

    Thread Starter
    Hyperactive Member pgrimes's Avatar
    Join Date
    Aug 2001
    Location
    sacramento
    Posts
    342
    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

  6. #6
    Hyperactive Member
    Join Date
    Aug 2002
    Location
    Fort Collins, CO
    Posts
    366
    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:
    PHP Code:
    <%@ Import Namespace="System" %>
    <%@ 
    Import Namespace="System.IO" %>
    <
    script language="C#" runat="server">
    protected 
    void btnSave_Click(object senderSystem.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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width