Trying to save an existing file on the webserver using a webservic

Discussion in 'ASP .Net Web Services' started by sonny, Dec 6, 2005.

  1. sonny

    sonny Guest

    Here's the code:
    private void SaveUserXml(string user, XmlDocument doc)
    {
    FileStream file;
    FileIOPermission perm;
    XmlTextWriter writer;
    string xml;

    try
    {
    doc = new XmlDocument();
    xml = Server.MapPath("/protoLogin") + "\\xml\\" + user + ".xml";

    file = File.Open(xml, FileMode.Create);
    writer = new XmlTextWriter(file, null);
    doc.WriteTo(writer);
    writer.Close();
    file.Close();
    }
    catch (Exception ex)
    {
    int i = 0;
    }
    }
    Here's the exception I get:
    >? ex.Message

    "Access to the path \"D:\\work\\protoLogin\\xml\\sonny.xml\" is denied."

    Any thoughts on this would be greatly appreciated.

    thx...sonny
    sonny, Dec 6, 2005
    #1
    1. Advertising

  2. sonny

    Jon Guest

    Give the user IIS is running under write access to that directory

    Jon

    "sonny" <> wrote in message
    news:...
    > Here's the code:
    > private void SaveUserXml(string user, XmlDocument doc)
    > {
    > FileStream file;
    > FileIOPermission perm;
    > XmlTextWriter writer;
    > string xml;
    >
    > try
    > {
    > doc = new XmlDocument();
    > xml = Server.MapPath("/protoLogin") + "\\xml\\" + user + ".xml";
    >
    > file = File.Open(xml, FileMode.Create);
    > writer = new XmlTextWriter(file, null);
    > doc.WriteTo(writer);
    > writer.Close();
    > file.Close();
    > }
    > catch (Exception ex)
    > {
    > int i = 0;
    > }
    > }
    > Here's the exception I get:
    >>? ex.Message

    > "Access to the path \"D:\\work\\protoLogin\\xml\\sonny.xml\" is denied."
    >
    > Any thoughts on this would be greatly appreciated.
    >
    > thx...sonny
    Jon, Dec 6, 2005
    #2
    1. Advertising

  3. sonny

    sonny Guest

    Re: Trying to save an existing file on the webserver using a webse

    Thanks Jon. I thought I had given the folder proper permissions, but I didn't.

    I can save over the existing file, now I just have to correct some logic :)

    ....sonny

    "Jon" wrote:

    > Give the user IIS is running under write access to that directory
    >
    > Jon
    >
    > "sonny" <> wrote in message
    > news:...
    > > Here's the code:
    > > private void SaveUserXml(string user, XmlDocument doc)
    > > {
    > > FileStream file;
    > > FileIOPermission perm;
    > > XmlTextWriter writer;
    > > string xml;
    > >
    > > try
    > > {
    > > doc = new XmlDocument();
    > > xml = Server.MapPath("/protoLogin") + "\\xml\\" + user + ".xml";
    > >
    > > file = File.Open(xml, FileMode.Create);
    > > writer = new XmlTextWriter(file, null);
    > > doc.WriteTo(writer);
    > > writer.Close();
    > > file.Close();
    > > }
    > > catch (Exception ex)
    > > {
    > > int i = 0;
    > > }
    > > }
    > > Here's the exception I get:
    > >>? ex.Message

    > > "Access to the path \"D:\\work\\protoLogin\\xml\\sonny.xml\" is denied."
    > >
    > > Any thoughts on this would be greatly appreciated.
    > >
    > > thx...sonny

    >
    >
    >
    sonny, Dec 7, 2005
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Monty
    Replies:
    3
    Views:
    4,085
    Monty
    Sep 29, 2006
  2. Replies:
    0
    Views:
    971
  3. Jeff Thies

    webserver and file save

    Jeff Thies, Jul 3, 2003, in forum: ASP General
    Replies:
    2
    Views:
    137
    Jeff Cochran
    Jul 3, 2003
  4. zoom
    Replies:
    6
    Views:
    74
    Mark Lawrence
    Mar 12, 2014
  5. Cameron Simpson
    Replies:
    0
    Views:
    65
    Cameron Simpson
    Mar 13, 2014
Loading...

Share This Page