System.IO.IOException: 函数不正确(debug不报错,直接运行exe报错)
错误详细内容:
---------------------------
---------------------------
System.IO.IOException: 函数不正确。
在 System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
在 System.IO.FileStream.WriteCore(Byte[] buffer, Int32 offset, Int32 count)
在 System.IO.FileStream.FlushWrite(Boolean calledFromFinalizer)
在 System.IO.FileStream.Dispose(Boolean disposing)
在 System.IO.Stream.Close()
在 System.IO.StreamWriter.Dispose(Boolean disposing)
在 System.IO.TextWriter.Dispose()
在 Lpts.Core.General.Common.AutoLogger.AddToLog(Int32 msgtype, String msgline, String linetypeblock) 位置 e:\SVN\Software\SourceCode\PC_Client\LptsCon\Lpts.Core.General\Common\AutoLogger.cs:行号 33****1安装路径: E:\SVN\Software\SourceCode\PC_Client\LptsCon\Install\ startup*******
---------------------------
确定
---------------------------
------------------------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------------------
代码如下:
/// <summary>
/// 写日志
/// </summary>
/// <param name="msgtype">0 error,1 success,2 warning,3 status update</param>
/// <param name="msgline">内容</param>
/// <param name="linetypeblock">类型如startup,method,socket</param>
public void AddToLog(int msgtype, string msgline, string linetypeblock = "generic")
{
try
{
lock (lck_AddLog)
{
string str = string.Format("{0}", DateTime.Now);
using (StreamWriter writer = File.AppendText(this.GetFullFile()))
{
object[] arg = new object[] { str, this.GetMsgType(msgtype), linetypeblock, msgline };
writer.WriteLine("[{0}][{1}][{2}] {3}", arg);
writer.Flush();
}
}
}
catch(IOException ioException)
{
MessageBoxEx.Show(ioException.ToString() + "****" + msgtype.ToString() + msgline + linetypeblock + "*******");
}
catch (Exception ex)
{
MessageBoxEx.Show(ex.ToString() + "****" + msgtype.ToString() + msgline + linetypeblock + "*******");
throw;
}
}