我有一个用于创建示例 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\...\Desktop\ProcessIndicativeData.xml", new UTF8Encoding());
XmlWriter synch_writer = new XmlTextWriter(@"C:\Users\...\Desktop\SyncIndicativeData.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), @"OutputFiles\ProcessIndicativeData.xml");
但这指向C:\Users\...\AppData\Local\Temp\...