Saturday 3 May 2014

How to use OpenFile Dialog and Copy that path


                                                                                                                                         Previous
                                                                                                                                              Next..
Here i will explain How to use OpenFile Dialog and Copy that path.

Step(1):Form
Drag and down a button and write its text as "Open".
Step(2):Code
Double click on button and write this code.

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

namespace First_Csharp_app
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

private void Button1_click(object sender, EventArgs e)
{
OpenFileDialog openfile = new OpenFileDialog ();

if(openfile .ShowDialog() ==System.Window.Forms.DialogResult.OK)
{
string strfilename = openfile .FileName;
MessageBox.show(strfilename);
}
}
Step(3):Output
Now run your application.
                                                                                                                                         Previous
                                                                                                                                              Next..

No comments:

Post a Comment

C# program Selection Sorting

Selection sort is a straightforward sorting algorithm. This algorithm search for the smallest number in the elements array and then swap i...