Click here to Skip to main content
15,912,400 members
Please Sign up or sign in to vote.
4.00/5 (2 votes)
See more:
So with my program i have recently had some feedback. The program updates the clients game folder with new files.

I had it setup so it finds the files, deletes them then copys over the new files. All went well..

I have now only really thought about the fact that people sometimes change the default install location.....

So NOW i am thinking about how to accomplish such an issue.



I made a Option where they can browse their computer and find the game folder. The location they find is displayed in a textbox EG:
C#
//Search For Gane Folder
private void folderBrowserDialog1_HelpRequest(object sender, EventArgs e)
{

}

private void button9_Click(object sender, EventArgs e)
{
    folderBrowserDialog1.ShowDialog();
    textBox1.Text = folderBrowserDialog1.SelectedPath;
}

private void Form1_Load(object sender, EventArgs e)
{
    textBox1.ReadOnly = true;
}


So i think that is right it works etc. Now here is the tricky part... Is their a way i can make it so the path selected in the above textbox is the path used?

So if they select the game path then they click the UPDATE button and it deletes files in the TEXTBOX selected path?

So they choose the install path with BROWSE, If a path in TEXTBOX exists then it uses TEXTBOXPATH in this:
C#
if (File.Exists(@"TEXTBOXPATH\Cool.inf"))
                        File.Delete(@"TEXTBOXPATH\Cool.inf");
                    File.Copy(@"C:\PROGRA~1\NEW PROGRAM\Cool.inf", @"TEXTBOXPATH\Cool,inf");



Also jsut realised does this mean ill also have to have an option to ask them to specify the Program Files path? As 64bit and 32 are different....
Posted
Comments
E.F. Nijboer 17-Jul-12 7:05am    
I would strongly advise you to rename the original file(s) instead of just deleting it/them. I (and probably a lot of users) hate it because it is very destructive. Another option is to send the file(s) to the recycle bin.
burgo855 17-Jul-12 21:14pm    
If they keep the original files in the same location even with a new name they will experience fps lag. I know this because i have already tried it...

If i place the files in recycle bin it will just eventually fill their bin making the program a hindrance as they have to empty recycle bin.

Besides i have the exact same files they will use so they can patch to and from each version.

1 solution

Hi,

hm, first i want to comment it's not very user friendly that users had to browse after the install path.
If users update the game, I assume they've started non-updated game once before, so you could use

C#
string fullPath = System.Reflection.Assembly.GetAssembly(typeof("Someofyourassemblyname")).Location;


and save that path in one of your .inf file or something.
For the case someone installed your game and runs the update immediately after installation, you've to sure it's started before updated once, but I think that's ok for users, worst case is to write some HelperProgram which executes after installation.

Be also careful with trying to delete and copy files to the ProgramFiles-Dir (both Program Files and Program Files(x86)) because of read-only permission.

For the case your software grows n' grows you will come to a point where it will be wasteful to write an own updater.
There are some open source automatic updater available, like:
http://autoupdater.codeplex.com/[^]

Create Setup with i.e (or with visual studio setup project, but not available with express edition)
http://www.jrsoftware.org/isinfo.php[^]

Updated: It's able to read the target directory from game link lnk, maybe this works for you. Is something registred in Windows Registry? Maybe another way to reach your goal ;)

Regards
 
Share this answer
 
v4
Comments
burgo855 17-Jul-12 21:11pm    
This is for an older game....

And their are 2 different versions. Players have to download and install patches manually and reinstall all the time which is time consuming... This program i am making has the patch files.

So i cant really check for updates etc because their will never be anymore updates....

Does anyone know how i can browse for the install folder and then somehow use echo or something to echo the messagebox1 path?
El_Codero 19-Jul-12 15:24pm    
Updated my solution with some more ideas, but I think you should think about a bit about your update/install strategy ;)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900