InPlaceBitmapMetadataWriter.TrySave Method ()

 
System_CAPS_noteNote

The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

Gets a value that indicates whether image metadata can be saved successfully.

Namespace:   System.Windows.Media.Imaging
Assembly:  PresentationCore (in PresentationCore.dll)

[SecurityCriticalAttribute]
public bool TrySave()

Return Value

Type: System.Boolean

true if bitmap metadata can be written successfully; otherwise, false.

The following code example demonstrates how to use the TrySave method to determine whether metadata can be written successfully to a Tagged Image File Format (TIFF) image.

Stream pngStream = new System.IO.FileStream("smiley.png", FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite);
PngBitmapDecoder pngDecoder = new PngBitmapDecoder(pngStream, BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.Default);
BitmapFrame pngFrame = pngDecoder.Frames[0];
InPlaceBitmapMetadataWriter pngInplace = pngFrame.CreateInPlaceBitmapMetadataWriter();
if (pngInplace.TrySave() == true)
{ pngInplace.SetQuery("/Text/Description", "Have a nice day."); }
pngStream.Close();

.NET Framework
Available since 3.0
Return to top
Show: