1

I am writing a program that will link two directories together. The idea is that someone with a game save file can sync with a directory in their Dropbox account. The program checks to see if Dropbox is installed and asks the user to select the two directories that he/she wishes to sync together. The game directory is stored in textBox_Game.Text and chosen Dropbox folder in textBox_DB.Text.

private void button_link_Click(object sender, EventArgs e)
        {
            string strCmdText;
            string sourceDir = textBox_Game.Text;
            string destinationDir = textBox_DB.Text;

            strCmdText = "/c MKLINK /J C:\Dest C:\Source";
            System.Diagnostics.Process.Start("CMD.exe", strCmdText);
        }
    }

I am currently doing a lot of programs in C++ so I'm familiar with the concept of outputting different variables and strings on a single line... however this is not c++... I didn't expect it to work but I tried strCmdText = "/c MKLINK /J " >> destinationDir >> " " >> sourceDir; just in case it would recommend something.

Obviously this is me attempting to use the command line. Also, if there is a way to do this without the need of installing libraries that would be great.

1 Answers1

1

Replace strCmdText = "/c MKLINK /J C:\Dest C:\Source"; with:

strCmdText = "/c MKLINK /J " + destinationDir + " " + sourceDir;
Moon
  • 33,439
  • 20
  • 81
  • 132