0

The program i am working on patches/updates the clients game...

The game it is made for is very old and it has 2 patches. For a person to play they need to install the patch. Once the patch is installed if they decide they want to play using the other patch they have to uninstall everything and start again.

The program i have made has two buttons. Version1 and Version2. When they click Version1 button it searches C:\PROGRA~1\Game\ For files, deletes specified files and then copy's files from the folder that comes with my program installed in program files. to the game path.

I realized i am using the above path. But if they aren't using windows 32 bit this will not work. How do i determine the clients program files location if i am using inno setup?

EDIT: Soory guys edited question my head wasn't straight when i asked my previous question.

4

2 回答 2

0

我认为你所追求的只是 string.IsNullOrEmpty()。您测试一下文本框文本是否为空或空,如下所示:

if (string.IsNullOrEmpty(textBox.Text))

..然后您基于此构建您的路径。例如:

string BuildFilePath()
{
    return string.Concat(!string.IsNullOrEmpty(textBox.Text) ? textBox.Text : @"C:\Program Files\Game\Folder\etc", @"\Cool.inf");
}

string filePath = BuildFilePath();

if (file.Exists(filePath))
    // etc..

我希望这是有道理的。

编辑:将复杂的串联移动到自己的方法中,因为我有点像“清洁代码”的传教士。

于 2012-07-18T02:11:24.797 回答
0

你能做这样的事情吗?

if (File.Exists(System.IO.Path.Combine(textBox1.Text,"Cool.inf")))
   File.Delete(System.IO.Path.Combine(textBox1.Text,"Cool.inf"));
于 2012-07-18T02:11:36.653 回答