获取打开文件的路径 OpenFileDialog op=new OpenFileDialog();string strPath=op.FileName; //这样就获得了要保存文件的全路径
if(openFileDialog.showDialog==DialogResult.OK){ src=openFileDialog.filename.toString();image.save("图片名",src);} 具体放哪你看着办吧!
首先添加一个按钮控件 代码 usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Data;usingSystem.Drawing;usingSystem.Linq;usingSystem.Text;usingSystem.Threading.Tasks;usingSystem.Windows.Forms;namespaceWindowsFormsApp8{publicpartialclassForm1:Form{publicForm1(){InitializeComponent();...
OpenFileDialog OP = new OpenFileDialog();OP.Filter = "*.bmp;*.jpg;*.gif|*.bmp;*.jpg;*.gif;*.jpeg";if (OP.ShowDialog() == DialogResult.OK){ string filePath = OP.FileName;this.imageList1.Images.Add(Image.FromFile(filePath));this.pictureBox1.BackgroundImage = this.image...
1、在工具箱里打打卡 对话框 拉一个OpenFileDialog到当前窗体 name为openFileDialog1 2、双击button按钮 private void button1_Click(object sender, EventArgs e){ this.openFileDialog1.Filter = "所有文件(*.*)|*.*|图片(*.gif)|*.gif|图片(*.png)|*.png";this.openFileDialog1.Title = ...
文件描述错误的OpenFileDialog问题是指在使用OpenFileDialog组件时,出现了文件描述错误的情况。这通常是由于以下原因导致的: 1. 文件路径错误:当指定的文件路径不存在或者文件...
public partial class Form1 : Form { public Form1() { InitializeComponent(); try { OpenFileDialog op = new OpenFileDialog(); op.ShowDialog(); } catch (Exception e) { MessageBox.Show(e.Message.ToString()); } } } But the problem is that nothing show up, not even the Form. When i ...
相信习惯以前winform开发的朋友们都对FolderBrowserDialog和OpenFileDialog这两个东东不陌生,但是在我最近做的WPF项目中才发现这两个东东在WPF中却不是默认存在的,郁闷,好歹WPF也出来几年了,咋个微软的同志不与时俱进呢。好了,说说具体怎么用吧。OpenFileD
OpenFileDialog dlgOpenFile = new OpenFileDialog(); dlgOpenFile.ShowReadOnly = true; if(dlgOpenFile.ShowDialog() == DialogResult.OK) { // If ReadOnlyChecked is true, uses the OpenFile method to // open the file with read/only access. string path = null; try { if (dlgOpenFile.ReadOn...
我一运行“OpenFileDialog dialog = new OpenFileDialog();dialog.ShowDialog();”就会抛出 ArgumentException: GCHandle value belongs to a different domain System.Runtime.InteropServices.GCHandle.op_Explicit (IntPtr value) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Runtime....