OpenFileDialog
发表于:2025-02-05 作者:千家信息网编辑
千家信息网最后更新 2025年02月05日,using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using Sy
千家信息网最后更新 2025年02月05日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安全错误
数据库的锁怎样保障安全
网络安全和信息委员会领导小组
三十岁学软件开发的基础
您无法在安全服务器上
数据库文件能转换成版式文件吗
分析自己适合软件开发工程师
服务器上面的黄线是干嘛用的
下列关于网络安全处理
sqlserver数据库专栏
正泰互联网科技
武汉 rfid软件开发
安卓软件开发培训机构
政府网络安全事件制度
黄埔区网络安全专题培训
浪潮ai服务器算力机组
抢答系统数据库
上海微型网络技术供应商
linux服务器域名
海南服务器租用虚拟主机云空间
数据库空集怎么解决
武汉未来科技城能源互联网
上海支酷网络技术有限公司
上海风眼网络技术公司
蓝牙模块传输数据到上位机数据库
腾讯服务器安全软件
大学手抄报一等奖网络安全
下列关于网络安全处理
隐藏数据库的商机
公司软件开发服务做账
国庆节前网络安全大检查
如何考核软件开发人员绩效