Search - Articles
DevASP.NET for ASP.NET, VB.NET, XML and C# (C-Sharp) Developers Tuesday, March 03, 2009
Dev Articles
Search Directory
ASP.NET
VB.Net
C-Sharp
SQL Server
 

How to Copy and Delete a Specific file with C#.net application in .NET 2.0

Author: DevASP
Download Source Code : 597_CopyFile.zip

In this simple article you will learn that how you can Copy and Delete Specific file.

Simply just create New Project of console application in C#.

 

Drag two text box and two buttons on form.

 

This Application Copy And Delete Specific file using .net interface. This is very use full Application for Beginners.  

 

Insert FolderBrowserDialog and openFileDialog in your application.

 

 

Now just write code against these events

 

 

private void Button2_Click(object sender, EventArgs e)

        {

            if (openFileDialog1.ShowDialog() == DialogResult.OK)

            {

                 f = new FileInfo(openFileDialog1.FileName);

                

                inp.Text = openFileDialog1.FileName;

              

            }

 

        }

 

        private void Button1_Click(object sender, EventArgs e)

        {

            folderBrowserDialog1.ShowDialog();

            outt.Text = folderBrowserDialog1.SelectedPath;

            destination = outt.Text;

        }

 

        private void button3_Click(object sender, EventArgs e)

        {

            try

            {

 

                f.CopyTo(destination + "\\" + f.Name);

                MessageBox.Show("File " + f.Name + " Copied");

 

 

            }

            catch (Exception ex)

            {

                              MessageBox.Show(ex.Message);

            }

        }

 

        private void button4_Click(object sender, EventArgs e)

        {

            f.Delete();

           

        }

 

        private void Form1_Load(object sender, EventArgs e)

        {

            this.Text = "DevAsp";

            this.BackColor = Color.Ivory;

        }

    }

Article Comments
Thanks alot

Posted on 1/18/2008 4:39:41 AM by Ashbin

Simple yet Powerfull.
Excellent work.
Thanks a lot.

Posted on 9/17/2008 2:00:33 AM by Sen K. Mathew

   
Add Article Comment:
Name :
Email Address :
   
Comments :
 
   
<< Adding any control to Datagrid control using C#

Disclaimer - Privacy
© 2002-2017 DevASP.net