Merge pull request #163 from wabbajack-tools/small-fixes

Change exception printing, and unset read-only during move.
This commit is contained in:
Timothy Baldridge 2019-11-10 16:31:18 -07:00 committed by GitHub
commit adcd991b0e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 18 deletions

View File

@ -497,24 +497,7 @@ namespace Wabbajack.Common
public static string ExceptionToString(this Exception ex)
{
var sb = new StringBuilder();
while (ex != null)
{
sb.AppendLine(ex.Message);
var st = new StackTrace(ex, true);
foreach (var frame in st.GetFrames())
sb.AppendLine(
$"{frame.GetFileName()}:{frame.GetMethod().Name}:{frame.GetFileLineNumber()}:{frame.GetFileColumnNumber()}");
ex = ex.InnerException;
}
return sb.ToString();
}
public static void CrashDump(Exception e)
{
File.WriteAllText($"{DateTime.Now.ToString("yyyyMMddTHHmmss_crash_log.txt")}", ExceptionToString(e));
return ex.ToString();
}
public static IEnumerable<T> DistinctBy<T, V>(this IEnumerable<T> vs, Func<T, V> select)

View File

@ -400,7 +400,21 @@ namespace Wabbajack.Lib
void CopyFile(string from, string to, bool use_move)
{
if (File.Exists(to))
{
var fi = new FileInfo(to);
if (fi.IsReadOnly)
fi.IsReadOnly = false;
File.Delete(to);
}
if (File.Exists(from))
{
var fi = new FileInfo(from);
if (fi.IsReadOnly)
fi.IsReadOnly = false;
}
if (use_move)
File.Move(from, to);
else