private void CloseFile() { try { if (_svgPage != null) { _svgPage.UnloadDocument(); } if (_xamlPage != null) { _xamlPage.UnloadDocument(); } if (_drawingPage != null) { _drawingPage.UnloadDocument(); } if (_canDeleteXaml && !String.IsNullOrEmpty(_xamlFilePath) && File.Exists(_xamlFilePath)) { File.Delete(_xamlFilePath); } _svgFilePath = null; _xamlFilePath = null; _canDeleteXaml = false; } catch { } }
private void CloseFile() { try { if (_svgPage != null) { _svgPage.UnloadDocument(); } if (_xamlPage != null) { _xamlPage.UnloadDocument(); } if (_drawingPage != null) { _drawingPage.UnloadDocument(); } if (_canDeleteXaml && !string.IsNullOrWhiteSpace(_xamlFilePath) && File.Exists(_xamlFilePath)) { File.Delete(_xamlFilePath); } if (!string.IsNullOrWhiteSpace(_drawingDir) && Directory.Exists(_drawingDir)) { string[] imageFiles = Directory.GetFiles(_drawingDir, "*.png"); if (imageFiles != null && imageFiles.Length != 0) { try { foreach (var imageFile in imageFiles) { if (File.Exists(imageFile)) { File.Delete(imageFile); } } } catch (IOException ex) { Trace.TraceError(ex.ToString()); // Image this, WPF will typically cache and/or lock loaded images } } } _svgFilePath = null; _xamlFilePath = null; _canDeleteXaml = false; } catch (Exception ex) { Trace.TraceError(ex.ToString()); } }