将文件夹从一个目录移动到另一个目录。在c#中

时间:2015-04-01 06:47:25

标签: c#

好的,所以我和其他几个人正试图从游戏启动器中移动一堆文件。到你选择的目录。

问题是,文件不会移动。

启动器的工作方式是,您在游戏上单击安装,它会将一堆文件安装到您选择的位置。但文件不会移动。

这里是代码。

    private void MoveFolders()
    {
        string sourceDir = Config.GetGamePath();
        string destinationDir = textBoxFolder.Text;
        try
        {
            if (Directory.Exists(sourceDir) == true)
            {
                if (bGameIsInstalled == true && textBoxFolder.TextLength > 0)
                {
                    Directory.Move(sourceDir, destinationDir);
                    bMoveFolders = true;
                }
                else
                {

                    MessageBox.Show("Select Arma 3 directory before starting game");
                }
            }
            else
            {
                // Do somthing about source directory not existing - 
            }
        }
        catch (Exception ex)
        {
            //TODO: Handle the execption that has been thrown will do this on launcher update
        }
    }

1 个答案:

答案 0 :(得分:0)

您可以使用CopyFile.正如您所说,这应该是一个安装程序,我不会将它们移动到另一个方向。只需复制它,因为在需要移除所有这些文件后,您无法再使用安装程序。 如果你调试它,请不要使用try和catch。简单地测试你的代码。

相关问题