OpenFileDialog
发表于:2025-12-03 作者:千家信息网编辑
千家信息网最后更新 2025年12月03日,using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using Sy
千家信息网最后更新 2025年12月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安全错误
数据库的锁怎样保障安全
计算机网络安全的认识
邵东软件开发有限公司
移动网络安全部
广西智慧社区软件开发
全华网络技术河北有限公司
软件开发岗常用的软件
软件开发考试题目
跑跑卡丁车城市运河服务器
如何给一个软件开发项目报价
华为软件开发工程师的一天
数据库as begin
灰度服务器啥意思
网络技术传播于生活
深圳web应用软件开发
脂质的数据库
乐山软件开发销售公司
惊无命是哪个服务器的
各类型数据库语句通用吗
广西企业软件开发哪家好
青岛达内软件开发
数据库AGE+int
java面试数据库结构
服务器时间自动跑快
交通局开展网络安全法宣传
软件开发类售后服务
爱迪尔数据库重装多少钱
window软件开发流程
网络安全发展观错误的是
什么设备必须要串口服务器
网络安全信息化委员