Skip to content

Commit

Permalink
ensure directory
Browse files Browse the repository at this point in the history
  • Loading branch information
kianzarrin committed Dec 16, 2022
1 parent 4a7192c commit 9711275
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion LoadOrder/Shared/SharedUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ internal class SharedUtil {
internal static void Serialize<T>(T obj, string filePath) {
var serializer = new XmlSerializer(typeof(T));
using (StreamWriter writer = new StreamWriter(filePath)) {
var dirInfo = new FileInfo(filePath).Directory;
if (!dirInfo.Exists) dirInfo.Create();
using (var xmlWriter = new XmlTextWriter(writer)) {
xmlWriter.Formatting = Formatting.Indented;
serializer.Serialize(xmlWriter, obj, NoNamespaces);
Expand All @@ -32,7 +34,7 @@ internal class SharedUtil {
public static T Deserialize<T>(string filePath) where T : class {
XmlSerializer ser = new XmlSerializer(typeof(T));
var dirInfo = new FileInfo(filePath).Directory;
if (dirInfo.Exists) dirInfo.Create();
if (!dirInfo.Exists) dirInfo.Create();
using (FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.Read)) {
return ser.Deserialize(fs) as T;
}
Expand Down
2 changes: 1 addition & 1 deletion Version.props
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<Project>
<PropertyGroup>
<AssemblyVersion>1.15.6.*</AssemblyVersion>
<AssemblyVersion>1.15.7.*</AssemblyVersion>
</PropertyGroup>
</Project>

0 comments on commit 9711275

Please sign in to comment.