In this blog we will know how to upload files in windows application.

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 File_upload

{

public partial class Form1 : Form

{

public Form1()

{

InitializeComponent();

}

private void btn_upload_Click(object sender, EventArgs e)

{

OpenFileDialog op1 = new OpenFileDialog();

op1.Multiselect = true;

op1.ShowDialog();

op1.Filter = "allfiles|*.xls";

textBox1.Text = op1.FileName;

int count = 0;

string[] FName;

foreach (string s in op1.FileNames)

{

FName = s.Split('\\');

File.Copy(s, "C:\\file\\" + FName[FName.Length - 1]);

count++;

}

MessageBox.Show(Convert.ToString(count) + " File(s) copied");

}

}

}

Thanks for reading