如题,怎么实现,望各位大侠指点
wpf刚接触,不知道有没有类似以前的那个 FileUPdate的控件,或者怎么可以实现这个效果
------解决方案--------------------------------------------------------
Microsoft.Win32.OpenFileDialog类打开文件.
上传的逻辑自己写
------解决方案--------------------------------------------------------
- C# code
private void FindPic_Click(object sender, RoutedEventArgs e) { OpenFileDialog dialog = new OpenFileDialog(); dialog.Filter = "PNG File(*.png)|*.png"; ; dialog.Multiselect = false; if (dialog.ShowDialog() == true) { FileStream fs = new FileStream(dialog.FileName, FileMode.Open, FileAccess.Read); BinaryReader br = new BinaryReader(fs); this._imageBinary = br.ReadBytes((int)fs.Length); this._imgLocalPath = dialog.FileName; br.Close(); fs.Close(); this.IMG.Source = ByteArrayToBitmapImage(this._imageBinary); } }BitmapImage ByteArrayToBitmapImage(byte[] byteArray) { BitmapImage bmp = null; try { bmp = new BitmapImage(); bmp.BeginInit(); bmp.StreamSource = new MemoryStream(byteArray); bmp.EndInit(); } catch { bmp = null; } return bmp; }