throw new Exception while keeping stack trace and inner exception information
问题 I have a FileSystemWatch program that I'm working on and if there's an error copying a file, I want to be able to know which file it failed on. At the same time, I'd like to be able to retain the stack trace, as well as the inner exception information. if (!found) { try { File.Copy(file, Path.Combine(watchDirectory, filename)); } catch (Exception ex) { WriteToLog(new Exception( String.Format("An error occurred syncing the Vault location with the watch location. Error copying the file {0}.