Click here to Skip to main content
15,885,216 members
Home / Discussions / C#
   

C#

 
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 
GeneralRe: How to copy and replace folder in desktop with C#/Winforms? Pin
George Tourtsinakis29-Jul-15 6:08
George Tourtsinakis29-Jul-15 6:08 
Questionintegrate payment gate away in asp.net website Pin
Member 1185937025-Jul-15 4:00
Member 1185937025-Jul-15 4:00 
AnswerRe: integrate payment gate away in asp.net website Pin
OriginalGriff25-Jul-15 4:13
mveOriginalGriff25-Jul-15 4:13 
AnswerRe: integrate payment gate away in asp.net website Pin
F-ES Sitecore25-Jul-15 9:20
professionalF-ES Sitecore25-Jul-15 9:20 
AnswerRe: integrate payment gate away in asp.net website Pin
George Tourtsinakis27-Jul-15 8:53
George Tourtsinakis27-Jul-15 8:53 
QuestionHello i need help for menustrip change theme Pin
Member 1186131324-Jul-15 7:02
Member 1186131324-Jul-15 7:02 
AnswerRe: Hello i need help for menustrip change theme Pin
OriginalGriff24-Jul-15 8:11
mveOriginalGriff24-Jul-15 8:11 
AnswerRe: Hello i need help for menustrip change theme Pin
Afzaal Ahmad Zeeshan24-Jul-15 8:11
professionalAfzaal Ahmad Zeeshan24-Jul-15 8:11 

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.