I’m working on adding a level editor to my game and every time I try to export the file it exports to Project_Name\bin\Debug\netcoreapp3.1\Content
instead of Project_Name\Content
which causes a problem when I try to publish the app and release it.
These are my save and load functions:
public static void Save<T>(string path, T obj) {
XmlSerializer xmlSerializer = new XmlSerializer(obj.GetType());
using (StreamWriter writer = new StreamWriter(path)) {
xmlSerializer.Serialize(writer, obj);
}
Debug.Print(path);
}
public static T Load<T>(string path) {
using (TextReader reader = new StreamReader(path)) {
XmlSerializer xml = new XmlSerializer(typeof(T));
return (T)xml.Deserialize(reader);
}
}
I’m avoiding using the IntermediateSerializer as it’s caused problems for me with difficulty importing the files and getting errors. This method works for saving and loading, but I just wish I could save directly into the Content folder without having to change anything so it’d all work for a published alpha build.
I’ve tried using Content.RootDirectory, System.AppDomain.CurrentDirectory, and even $"{System.AppDomain.CurrentDomain.BaseDirectory}" but nothing has worked. Is there any way I can just save the file into the main content directory in the solution explorer without hardcoding that exact file address?