2015-04-01 161 views
0

好的,所以我和其他几个人正试图从游戏启动器移动一堆文件。到你选择的目录。将文件夹从一个目录移动到另一个目录。在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 
     } 
    } 
+0

也许会抛出一些异常? – 2015-04-01 06:49:27

+1

我们不会调试您的代码,当您完成该操作后,您会发现源/目标字符串不是您想要的。或者它会抛出一个错误(权限?),我们可以从那里去。 – Mathemats 2015-04-01 06:51:21

+0

你能否提供'sourceDir'和'destinationDir'的样本(它们是否有相同的音量/盘符)? – 2015-04-01 06:51:30

回答

0

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

+0

但是,它也表示文件已经存在于目录中 – 2015-04-01 07:02:10

+0

你有团队尖峰吗?哈哈,我很想跟你谈谈这件事。我和我的朋友现在疯狂地坚持下去。如果你加入ts3.life-studios.net:3537 – 2015-04-01 07:07:39

+0

并戳我,我布雷克亨德里克斯 – 2015-04-01 07:08:46

相关问题