I am trying to save a LINQ XML document using a StreamWriter. Using the following code works fine when the document is small (~6kb on disk) but doesn't work when the file is larger (~66kb on disk). If I replace the relative path with an absolute path it works fine in both situations. Is there any reason why the relative path should fail with a larger file?
NB: I am not getting any exception, but no file is created/written to unless I use an absolute path (with the larger dataset - smaller dataset works fine with relative path)
XDocument xMap = new XDocument( ... );
// Works for small file but not large
using (StreamWriter writer = new StreamWriter("map.xml", false, new UTF8Encoding(false))) {
xMap.Save(writer);
}
// Works consistently
using (StreamWriter writer = new StreamWriter(@"c:\data\map.xml", false, new UTF8Encoding(false))) {
xMap.Save(writer);
}