我正在使用MonoDevelop开发一个ubuntu统一应用程序。
如何使用C#读取dconf设置?
我可以使用C#访问GSettings吗?
我真正需要的是密钥/org/gnome/desktop/interface/font-name
的价值。
更新
我的快速黑客如下:
private string GetFontName()
{
string font = "Ubuntu 11";
Process p = new Process {
StartInfo = new ProcessStartInfo {
FileName = "gsettings",
Arguments = "get org.gnome.desktop.interface font-name",
UseShellExecute = false,
RedirectStandardOutput = true,
CreateNoWindow = true
}
};
p.Start();
while (!p.StandardOutput.EndOfStream)
font = p.StandardOutput.ReadLine();
p.WaitForExit();
return font.Trim(new char[]{'\''});
}
答案 0 :(得分:-4)
我从未与Ubuntu和Mono合作过。 我认为下面的颂歌可能对你有帮助。
using System;
using System.IO;
namespace FileAccess
{
class MainClass
{
public static void Main (string[] args)
{
string FileName="TestFile.txt";
// Open the file into a StreamReader
StreamReader file = File.OpenText(FileName);
// Read the file into a string
string s = file.ReadToEnd();
// Close the file so it can be accessed again.
file.Close();
// Add a line to the text
s += "A new line.\n";
// Hook a write to the text file.
StreamWriter writer = new StreamWriter(FileName);
// Rewrite the entire value of s to the file
writer.Write(s);
// Add a single line
writer.WriteLine("Add a single line.");
// Close the writer
writer.Close();
}
}
}