我有一个用于创建示例xml数据的测试。当前输出正在保存到我的桌面上。我想做的是将文件保存到测试项目中的一个文件夹中,即/outputs
。有没有一种方法我可以用反射或其他方式来做到这一点?
[TestMethod]
public void ProduceSampleIndicativeData()
{
var process_serializer = new XmlSerializer(typeof(ProcessIndicativeDataType));
var sync_serailizer = new XmlSerializer(typeof (SyncIndicativeDataType));
XmlWriter process_writer = new XmlTextWriter(@"C:Users...DesktopProcessIndicativeData.xml", new UTF8Encoding());
XmlWriter synch_writer = new XmlTextWriter(@"C:Users...DesktopSyncIndicativeData.xml",new UTF8Encoding());
var namespaces = new XmlSerializerNamespaces();
namespaces.Add("", "http://www.hr-xml.org/3");
namespaces.Add("oa", "http://www.openapplications.org/oagis/9");
namespaces.Add("xsi", "http://www.w3.org/2001/XMLSchema-instance");
process_serializer.Serialize(process_writer, processIndicativeData, namespaces);
sync_serailizer.Serialize(synch_writer,syncIndicativeData,namespaces);
}
我试过
string ProcessIndicativeDataLocation = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), @"OutputFilesProcessIndicativeData.xml");
但这指向C:Users...AppDataLocalTemp...
System.IO.Directory.GetCurrentDirectory()怎么样http://msdn.microsoft.com/en-us/library/system.io.directory.getcurrentdirectory.aspx