config: Use Xml.Linq for writing XML
This commit is contained in:
parent
30c4d10967
commit
d5a7620683
|
@ -536,7 +536,6 @@ namespace SparkleShare {
|
|||
string folder_name = Path.GetFileName (PreviousPath);
|
||||
folder_name = folder_name.ReplaceUnderscoreWithSpace ();
|
||||
|
||||
// TODO: Open SparkleShare/$HOST
|
||||
SparkleShare.Controller.OpenSparkleShareFolder (folder_name);
|
||||
FinishPageCompleted ();
|
||||
}
|
||||
|
|
|
@ -16,9 +16,10 @@
|
|||
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Xml;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace Sparkles {
|
||||
|
||||
|
@ -42,6 +43,7 @@ namespace Sparkles {
|
|||
public readonly string FilePath;
|
||||
public readonly string TmpPath;
|
||||
public readonly string BinPath;
|
||||
|
||||
public readonly string LogFilePath;
|
||||
|
||||
|
||||
|
@ -115,11 +117,10 @@ namespace Sparkles {
|
|||
CreateInitialConfig ();
|
||||
|
||||
} else {
|
||||
throw new XmlException (FilePath + " does not contain a valid config XML structure.");
|
||||
throw;
|
||||
}
|
||||
|
||||
} finally {
|
||||
Load (FilePath);
|
||||
TmpPath = Path.Combine (DirectoryPath, "tmp");
|
||||
Directory.CreateDirectory (TmpPath);
|
||||
}
|
||||
|
@ -138,17 +139,16 @@ namespace Sparkles {
|
|||
user_name = user_name.TrimEnd (',');
|
||||
}
|
||||
|
||||
// TODO: Don't do this manually
|
||||
string n = Environment.NewLine;
|
||||
File.WriteAllText (FilePath,
|
||||
"<?xml version=\"1.0\" encoding=\"UTF-8\" ?>" + n +
|
||||
"<sparkleshare>" + n +
|
||||
" <user>" + n +
|
||||
" <name>" + user_name + "</name>" + n +
|
||||
" <email>Unknown</email>" + n +
|
||||
" </user>" + n +
|
||||
" <notifications>True</notifications>" + n +
|
||||
"</sparkleshare>");
|
||||
XElement xml =
|
||||
new XElement ("sparkleshare",
|
||||
new XElement ("user",
|
||||
new XElement ("name", user_name),
|
||||
new XElement ("email", "Unknown")
|
||||
),
|
||||
new XElement ("notifications", bool.TrueString)
|
||||
);
|
||||
|
||||
LoadXml (xml.ToString ());
|
||||
}
|
||||
|
||||
|
||||
|
@ -351,9 +351,6 @@ namespace Sparkles {
|
|||
|
||||
void Save ()
|
||||
{
|
||||
if (!File.Exists (FilePath))
|
||||
throw new FileNotFoundException (FilePath + " does not exist");
|
||||
|
||||
Save (FilePath);
|
||||
Logger.LogInfo ("Config", "Wrote to '" + FilePath + "'");
|
||||
}
|
||||
|
|
|
@ -60,6 +60,7 @@
|
|||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="AuthenticationInfo.cs" />
|
||||
|
|
Loading…
Reference in a new issue