OpenFileDialog
发表于:2026-11-03 作者:千家信息网编辑
千家信息网最后更新 2026年11月03日,using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using Sy
千家信息网最后更新 2026年11月03日OpenFileDialog
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApp4
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)//读取文本 { this.openFileDialog1.Filter = "*.txt|*.txt"; if (openFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK) { StreamReader sr = new StreamReader(openFileDialog1.FileName); MessageBox.Show(sr.ReadToEnd()); sr.Close(); } } private void button2_Click(object sender, EventArgs e)//选择图片 { this.openFileDialog1.Filter = "(*.jpg;*.jpg;*.jpeg;*.gif;*.png)|*.jpg;*.jpeg;*.gif;*.png"; if (openFileDialog1.ShowDialog() == DialogResult.OK) { MessageBox.Show("" + openFileDialog1.FileName); pictureBox1.ImageLocation = openFileDialog1.FileName; } } //拷贝到制定文件夹 private void button4_Click(object sender, EventArgs e) { string oldpath = pictureBox1.ImageLocation; string fileName = System.IO.Path.GetFileName(oldpath).ToString(); string copypath = System.IO.Directory.GetCurrentDirectory() + "/images/";//当前运行程序的images文件夹 if (!Directory.Exists(copypath))//如果这个目录不存在就创建 { Directory.CreateDirectory(copypath); } File.Copy(pictureBox1.ImageLocation, copypath + fileName, true); MessageBox.Show("保存成功"); } //另存 private void button3_Click(object sender, EventArgs e) { SaveFileDialog saveFileDialog1 = new SaveFileDialog(); string oldpath = pictureBox1.ImageLocation; string fileName = System.IO.Path.GetFileName(oldpath).ToString(); string houzui = System.IO.Path.GetExtension(oldpath).ToString(); saveFileDialog1.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*"; saveFileDialog1.FilterIndex = 2; saveFileDialog1.RestoreDirectory = true; if (saveFileDialog1.ShowDialog() == DialogResult.OK) { MessageBox.Show(saveFileDialog1.FileName); File.Copy(pictureBox1.ImageLocation, saveFileDialog1.FileName+houzui, true); } }}}
文件
文件夹
成功
图片
拷贝
文本
目录
程序
运行
选择
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
中国互联网科技工作委员会毛军
科技赋能下的互联网金融
互联网巨头科技公司
科技类互联网
北京互联网科技
金融科技与互联网金融
互联网 科技创新
猪兼强互联网科技
互联网未来科技
天津摩尔互联网科技
互联网科技汛
海南购全球互联网科技
崇明区互联网教育科技售后服务
洛阳共同富裕互联网科技有限公司
智帮互联网科技公司最近动向
浙南科技城互联网大厦招聘
信承诺互联网科技有限公司
济南小医互联网科技有限公司招聘
黑龙江互联网科技公司
上海旺乐尼互联网科技有限公司
有格互联网科技
高科技互联网
互联网 视角下的科技创新
互联网科技论坛
互联网前沿科技
互联网 科技服务平台
昭通互联网科技选哪家
富国互联网金融科技混合基金
世界互联网科技成果奖
众联互联网络科技