BigRedButtonOfDeath.WPF.MainWindow.GetImage C# (CSharp) Метод

GetImage() статический приватный Метод

static private GetImage ( string path ) : ImageSource
path string
Результат ImageSource
        static ImageSource GetImage(string path)
        {
            BitmapImage img = null;
            try
            {
                using (FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read))
                {
                    using (MemoryStream ms = new MemoryStream())
                    {
                        int byRead = -1;
                        byte[] bytes = new byte[32768];
                        do
                        {
                            byRead = fs.Read(bytes, 0, bytes.Length);
                            if (byRead > 0)
                            {
                                ms.Write(bytes, 0, byRead);
                            }
                        } while (byRead > 0);
                        ms.Seek(0, SeekOrigin.Begin);
                        img = new BitmapImage();
                        img.BeginInit();
                        img.StreamSource = ms;
                        img.CacheOption = BitmapCacheOption.OnLoad;
                        img.EndInit();
                        img.Freeze();

                    }
                }
            }
            catch { }
            return img;
        }