Webdev.Webserver has stopped working
- by Alexander
When I execute the code saveXML below it generates the error above, why??
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Xml.Serialization;
using System.IO;
/// <summary>
/// Summary description for Post
/// </summary>
public class Post
{
private int postIDCounter = 0;
private String DateCreated;
public Post()
{
Author = "unknown";
Title = "unkown";
Content = "";
DateCreated = DateTime.Now.ToString();
ID = postIDCounter++;
}
public int ID
{
get { return ID; }
set
{
if (ID != value)
ID = value;
}
}
public string Author
{
get { return Author; }
set
{
if (Author != value)
Author = value;
}
}
public string Title
{
get { return Title; }
set
{
if (Title != value)
Title = value;
}
}
public string Content
{
get { return Content; }
set
{
if (Content != value)
Content = value;
}
}
public void saveXML()
{
XmlSerializer serializer = new XmlSerializer(typeof(Post));
Stream writer = new FileStream("..'\'App_Data'\'posts'\'" + new Guid(ID.ToString()).ToString() + ".xml", FileMode.Create);
serializer.Serialize(writer, this);
writer.Close();
}
}