The documentation for the XmlWriter.Create Method (string) function has ArgumentNullException as the only exception that will be thrown for this function. I've found that System.IO.DirectoryNotFoundException can also be thrown here.
The AppDomain.CurrentDomain.BaseDirectory does not terminate with a back slash if you are running a unit test - you need to add this if you're going to append further directories. To make the using of AppDomain.CurrentDomain.BaseDirectory work in both unit tests and production code you might want to create a property to access the AppDomain.CurrentDomain.BaseDirectory that looks something like this:
return AppDomain.CurrentDomain.BaseDirectory.EndsWith(@"\") ?
AppDomain.CurrentDomain.BaseDirectory + @"\";
Post a Comment