Hallo zusammen,
ich hoffe ich bin hier richtig.
Also ich habe folgendes Problem:
Code:
//Image myImage3 = new Image();
BitmapImage bi3 = new BitmapImage();
bi3.BeginInit();
bi3.UriSource = new Uri(path + "/" + sC, UriKind.Absolute);
bi3.EndInit();
img_Bild.Source = bi3;
img_BildToolTip.Source = bi3;
img_Bild.Tag = path + "/" + sC;
txb_Bild.Text = sC;
Das funktioniert soweit prima.
Nun möchte ich zu einem späteren Zeitpunkt das Verzeichnis in dem sich das Bild befindet umbenennen, das geht nicht, da der Zugriff auf das Verzeichnis nicht möglich ist.
Wenn ich das Bild nicht lade, ist das umbenennen des Verzeichnisses ohne Probleme möglich.
Was muss ich noch ändern um das Verzeichnis wieder "freizugeben"
Danke im voraus
mfg
HB-Mänla
Bitte verwende wie jeder andere Forenbenutzer entsprechende Code-Tags im Editor.
[Hinweis] Wie poste ich richtig? Punkt 6
- performance is a feature -
Microsoft MVP - @Website - @AzureStuttgart - github.com/BenjaminAbt - Sustainable Code
Hi HB-Mänla,
du mußt die CacheOption-Eigenschaft auf BitmapCacheOption.OnLoad festlegen:
public static ImageSource BitmapFromUri(Uri source)
{
var bitmap = new BitmapImage();
bitmap.BeginInit();
bitmap.UriSource = source;
bitmap.CacheOption = BitmapCacheOption.OnLoad;
bitmap.EndInit();
return bitmap;
}
Ansonsten das, was Abt sagt.
Weeks of programming can save you hours of planning