[英]Write to local text file on a mac with mono and c#
我正在嘗試寫入Mac上應用程序文件夾中的日志文件。 我目前正在使用Mono。 我讀過StreamWriter這是有問題的。 有誰有更好的解決方案?
private void label2_Click(object sender, EventArgs e)
{
StreamWriter writer = new StreamWriter("log.txt");
writer.WriteLine("File created using StreamWriter class.");
writer.Close();
}
您可以通過調用獲取包含程序集的目錄
Path.GetDirectoryName(typeof(SomeType).Assembly.Location)
然后,您可以通過調用Path.Combine()
將get路徑添加到該目錄中的文件名。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.