Image upload in C#(windows application)

In windows application file upload operation is not much easy just like web application.But we can implement this in windows application using other way. 

Needed Controls:

Openfiledialog,Button,TextBox

Coding part :

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;

namespace DemoWindowsApplication
{
    public partial class FileUpload : Form
    {
        public FileUpload()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            DialogResult result = openFileDialog1.ShowDialog();
            if (result == DialogResult.OK) // Test result.
            {
                textBox1.Text = openFileDialog1.FileName;
            }

        }

        private void button2_Click(object sender, EventArgs e)
        {
            int count = 0;
            string[] FilenameName;
            foreach (string item in openFileDialog1.FileNames)
            {
                FilenameName = item.Split('\\');
                File.Copy(item, @"Images\" + FilenameName[FilenameName.Length - 1]);
                count++;
            }
            MessageBox.Show(Convert.ToString(count) + " File(s) copied");
        }
    }
}



Lets try it..

By Varun K.R




Comments

Popular posts from this blog

Web design, Mobile Application, Seo, Digital Marketing, Website development, Software Company in Thrissur, Kerala, India