gpt4 book ai didi

c# - 我的日志管理器的路径共享违规

转载 作者:行者123 更新时间:2023-11-30 17:05:25 24 4
gpt4 key购买 nike

<分区>

我正在使用此代码在 C# monotouch 应用程序中保存日志:

public static void  writeExeption(string message){
string path= StorageClass .LogsPath ;
string filepath= Path.Combine (path ,"Log.txt");
if(!File.Exists (filepath )){
using (StreamWriter sw = File.CreateText(filepath))
{
sw.WriteLine ("--------------------------------------------------------------------------" +
"--------------------");
sw.WriteLine("blahblah...");
sw.WriteLine ("--------------------------------------------------------------------------" +
"--------------------");
}
}
using (StreamWriter w = File.AppendText(filepath ))
{
Log(message , w);
}
}

public static void Log(string logMessage, TextWriter w)
{
w.Write("\r\nLog Entry : ");
w.WriteLine("{0} {1}", DateTime.Now.ToLongTimeString(),
DateTime.Now.ToLongDateString());
w.WriteLine(" :");
w.WriteLine(" :{0}", logMessage);
w.WriteLine ("--------------------------------------------------------------------------" +
"--------------------");
}

但是在应用程序中我得到这个错误:

 Sharing violation on path 'File Path'

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com