网创优客建站品牌官网
为成都网站建设公司企业提供高品质网站建设
热线:028-86922220
成都专业网站建设公司

定制建站费用3500元

符合中小企业对网站设计、功能常规化式的企业展示型网站建设

成都品牌网站建设

品牌网站建设费用6000元

本套餐主要针对企业品牌型网站、中高端设计、前端互动体验...

成都商城网站建设

商城网站建设费用8000元

商城网站建设因基本功能的需求不同费用上面也有很大的差别...

成都微信网站建设

手机微信网站建站3000元

手机微信网站开发、微信官网、微信商城网站...

建站知识

当前位置:首页 > 建站知识

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;

创新互联公司是一家专注于做网站、成都做网站与策划设计,中原网站建设哪家好?创新互联公司做网站,专注于网站建设十年,网设计领域的专业建站公司;建站业务涵盖:中原等地区。中原做网站价格咨询:028-86922220

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);
        }
    }

}

}

另外有需要云服务器可以了解下创新互联scvps.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。


网页题目:OpenFileDialog-创新互联
文章地址:http://bjjierui.cn/article/dhjsph.html

其他资讯