Click here to Skip to main content
15,920,708 members
Home / Discussions / C#
   

C#

 
GeneralRe: how do i insert data into a table Pin
jamesmc153527-Jul-15 2:40
jamesmc153527-Jul-15 2:40 
AnswerRe: how do i insert data into a table Pin
Pete O'Hanlon27-Jul-15 0:24
mvePete O'Hanlon27-Jul-15 0:24 
QuestionDisplay data from SQL database to HTML page in table format using Angular JS Pin
iamcpmember27-Jul-15 0:01
professionaliamcpmember27-Jul-15 0:01 
AnswerRe: Display data from SQL database to HTML page in table format using Angular JS Pin
Richard MacCutchan27-Jul-15 0:18
mveRichard MacCutchan27-Jul-15 0:18 
QuestionPicture Viewer. Pin
Member 1186549926-Jul-15 23:07
Member 1186549926-Jul-15 23:07 
AnswerRe: Picture Viewer. Pin
Pete O'Hanlon26-Jul-15 23:18
mvePete O'Hanlon26-Jul-15 23:18 
AnswerRe: Picture Viewer. Pin
Sebastiaan Lubbers29-Jul-15 0:32
professionalSebastiaan Lubbers29-Jul-15 0:32 
QuestionC# Read/Write PowerPoint.PageSetup.FirstSlideNumber Pin
Member 1185927326-Jul-15 14:31
Member 1185927326-Jul-15 14:31 
AnswerRe: C# Read/Write PowerPoint.PageSetup.FirstSlideNumber Pin
Richard Deeming27-Jul-15 2:02
mveRichard Deeming27-Jul-15 2:02 
QuestionRe: C# Read/Write PowerPoint.PageSetup.FirstSlideNumber Pin
Eddy Vluggen27-Jul-15 2:02
professionalEddy Vluggen27-Jul-15 2:02 
GeneralGridView - Update query Pin
Member 1186428526-Jul-15 8:45
Member 1186428526-Jul-15 8:45 
GeneralRe: GridView - Update query Pin
Wes Aday26-Jul-15 9:12
professionalWes Aday26-Jul-15 9:12 
GeneralRe: GridView - Update query Pin
Sascha Lefèvre26-Jul-15 9:49
professionalSascha Lefèvre26-Jul-15 9:49 
QuestionHow to copy and replace folder in desktop with C#/Winforms? Pin
George Tourtsinakis26-Jul-15 7:40
George Tourtsinakis26-Jul-15 7:40 
QuestionRe: How to copy and replace folder in desktop with C#/Winforms? Pin
Richard MacCutchan26-Jul-15 22:24
mveRichard MacCutchan26-Jul-15 22:24 
AnswerRe: How to copy and replace folder in desktop with C#/Winforms? Pin
George Tourtsinakis26-Jul-15 22:41
George Tourtsinakis26-Jul-15 22:41 
Let's say I have a directory c:\test with some files in it.I want this directory to be copied in desktop with every file in it.If it exists I want to replace it with the new files .I m making a program so I can have backup of my projects easily and not copying pasting with windows clicks all the time .

This is the whole code which creates a folder in desktop Downloads\Downloads and also some files are copies to desktop\Downloads and some others to desktop\Downloads\Downloads.

C#


C#
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;//We need this namespace to be used so we can have the file class
//that gives us the ability to copy,delte files etc.

namespace EasyCopyFiles
{
    public partial class Form1 : Form
    {


        string desktop = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);


        public Form1()
        {
            InitializeComponent();



        }

        private void button1_Click(object sender, EventArgs e)
        {


            foreach (string file in Directory.GetFiles(SourceOneToCopyBox.Text))//SourceOneToCopy
                //textbox we read from user input exammple c:\test
            {
                //OutputDirectory1 also a text box we read from user example d:\test
                File.Copy(file, Path.Combine(OutputDirectory1.Text, Path.GetFileName(file)), true);

                if (YesRadioButton.Checked == true)
                {
                    desktop += "\\Downloads";//With the \\ we create the path we want
                    if (!System.IO.Directory.Exists(desktop))
                    {

                        DirectoryInfo directory = Directory.CreateDirectory(desktop);

                    }

                    File.Copy(file, Path.Combine(desktop, Path.GetFileName(file)), true);


                }

            }
        }

    }
}



Thank you again I m so close to it.Thank you a lot.
GeneralRe: How to copy and replace folder in desktop with C#/Winforms? Pin
Richard MacCutchan26-Jul-15 23:01
mveRichard MacCutchan26-Jul-15 23:01 
GeneralRe: How to copy and replace folder in desktop with C#/Winforms? Pin
George Tourtsinakis27-Jul-15 1:18
George Tourtsinakis27-Jul-15 1:18 
GeneralRe: How to copy and replace folder in desktop with C#/Winforms? Pin
Richard MacCutchan27-Jul-15 1:34
mveRichard MacCutchan27-Jul-15 1:34 
GeneralRe: How to copy and replace folder in desktop with C#/Winforms? Pin
George Tourtsinakis27-Jul-15 2:10
George Tourtsinakis27-Jul-15 2:10 
GeneralRe: How to copy and replace folder in desktop with C#/Winforms? Pin
Richard MacCutchan27-Jul-15 2:12
mveRichard MacCutchan27-Jul-15 2:12 
GeneralRe: How to copy and replace folder in desktop with C#/Winforms? Pin
George Tourtsinakis27-Jul-15 8:42
George Tourtsinakis27-Jul-15 8:42 
GeneralRe: How to copy and replace folder in desktop with C#/Winforms? Pin
Pete O'Hanlon27-Jul-15 9:53
mvePete O'Hanlon27-Jul-15 9:53 
GeneralRe: How to copy and replace folder in desktop with C#/Winforms? Pin
George Tourtsinakis28-Jul-15 0:14
George Tourtsinakis28-Jul-15 0:14 
GeneralRe: How to copy and replace folder in desktop with C#/Winforms? Pin
Pete O'Hanlon28-Jul-15 0:37
mvePete O'Hanlon28-Jul-15 0:37 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.