zoukankan      html  css  js  c++  java
  • WinForm上传文件,下载文件

    上传文件:
    使用OpenFileDialog控件选择文件,
    具体代码示例:

     
    private void btnUpLoadPic_Click(object sender, EventArgs e)
            {
                //文件类型过滤
                openFileDialog1.Filter = "图像文件(*.jpg,*.bmp,*.gif)|*.jpg;*.bmp;*.gif";
                if (openFileDialog1.ShowDialog() == DialogResult.OK)
                {
                    //得到文件路径全名
                    imageFilePath = openFileDialog1.FileName;
                    //得到文件名
                    currentImageName = imageFilePath.Substring(imageFilePath.LastIndexOf('\') + 1);
                    //将选择的图片复制到程序文件夹里(需要IO库)
                    //DirectoryInfo directoryInfo=new DirectoryInfo("\Debug\");
                    if (new FileInfo(currentImageName).Exists)
                    {
                        MessageBox.Show("图片名与图片" + currentImageName + "重名,请修改名称后再次上传");
                    }
                    else
                    {
                        picProduc_add.Image = Image.FromFile(imageFilePath);
                        lblImageName_add.Text = currentImageName;
                    }
    
                }
            }
    



    下载文件:
    使用FolderBrowserDialog控件选择文件存放地点:

     //设置浏览文件夹窗口的标题
     folderBrowserDialog1.Description = "选择导出的Excle的存放地点";
                DialogResult result = folderBrowserDialog1.ShowDialog();
                if (result == DialogResult.OK)
                {
                    this.textBox1.Text = folderBrowserDialog1.SelectedPath;
                }
    
  • 相关阅读:
    基于最大最小距离的分类数目上限K确定的聚类方法
    diff函数(matlab)
    CreateThread线程函数
    套接字基础
    基于TCP套接字实现的简单Demo
    使用httpwatch抓包
    TLV----Demo讲解
    关于位图边缘的检测定位
    从txt中读入数据到数组中(fscanf)
    C语言运算符的优先级
  • 原文地址:https://www.cnblogs.com/xcxcxcxc/p/5541210.html
Copyright © 2011-2022 走看看