FileSystemWatcher
private void btnEdit_Click(object sender, RoutedEventArgs e) { if (!File.Exists(lastImage)) return; FileSystemWatcher izleyici = new FileSystemWatcher(System.IO.Path.GetDirectoryName( lastImage), System.IO.Path.GetFileName(lastImage)); izleyici.Changed += izleyici_Changed; izleyici.NotifyFilter = NotifyFilters.LastWrite; izleyici.EnableRaisingEvents = true; ProcessStartInfo info = new ProcessStartInfo(); info.FileName = lastImage; info.Verb = "edit"; Process.Start(info); } void izleyici_Changed(object sender, FileSystemEventArgs e) { //I want to add code here to release the file. Dispose() not worked for me setImageSource(lastImage); } void setImageSource(string file) { var bitmap = new BitmapImage(); using (var stream = new FileStream(file, FileMode.Open, FileAccess.Read, FileShare.Read)) { bitmap.BeginInit(); bitmap.CacheOption = BitmapCacheOption.OnLoad; bitmap.StreamSource = stream; bitmap.EndInit(); } ssreview.Source = bitmap; }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)