5 Replies - 389 Views - Last Post: 15 February 2013 - 08:22 AM Rate Topic: -----

#1 xKillerKev7x  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 11-February 13

Recognizing the install directory

Posted 14 February 2013 - 05:39 PM

Hey everyone I want to get a variable to recognizable the install directory.. How would I do this?
Is This A Good Question/Topic? 0
  • +

Replies To: Recognizing the install directory

#2 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 8890
  • View blog
  • Posts: 33,338
  • Joined: 12-June 08

Re: Recognizing the install directory

Posted 14 February 2013 - 05:51 PM

Like the environment's "CurrentDirectory"?

http://msdn.microsof...nvironment.aspx
Was This Post Helpful? 0
  • +
  • -

#3 xKillerKev7x  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 11-February 13

Re: Recognizing the install directory

Posted 14 February 2013 - 06:09 PM

View Postmodi123_1, on 14 February 2013 - 05:51 PM, said:

Like the environment's "CurrentDirectory"?

http://msdn.microsof...nvironment.aspx


a good example is lets say its installed to C:\Kevin\Example\ I want it to automatically look for that but also add my own custom to it like C:\Kevin\Example\Patches\Game.txt

Thanks guys :D
Was This Post Helpful? 0
  • +
  • -

#4 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 8890
  • View blog
  • Posts: 33,338
  • Joined: 12-June 08

Re: Recognizing the install directory

Posted 14 February 2013 - 06:14 PM

Okay.. I am not sure if that is a question or what. Did you read up on 'current directory'?
Was This Post Helpful? 0
  • +
  • -

#5 Skydiver  Icon User is offline

  • Code herder
  • member icon

Reputation: 3449
  • View blog
  • Posts: 10,643
  • Joined: 05-May 12

Re: Recognizing the install directory

Posted 15 February 2013 - 06:22 AM

CurrentDirectory is good only until that program brings up an OpenFileDialog or SaveFileDialog and the user changes the current directory. (The programmer has to consciously set the RestoreDirectory property to true since the default value is false. Since the current crop of programmers just use Intellisense and don't bother to read the documentation, the chances of a programmer knowing that they should set RestoreDirectory to true is low.)
Was This Post Helpful? 0
  • +
  • -

#6 Curtis Rutland  Icon User is online

  • (╯□)╯︵ (~ .o.)~
  • member icon


Reputation: 4419
  • View blog
  • Posts: 7,685
  • Joined: 08-June 10

Re: Recognizing the install directory

Posted 15 February 2013 - 08:22 AM

Well, there's at least one other option:

Application.ExecutablePath

That returns a string with the path of the actual executable. From that, you can parse the directory using Path.GetDirectoryName. Or you could make a FileInfo from it and get the directory that way. Regardless, that doesn't have to deal with the messy idea of a "current path".

To "add your own custom" (directory names, I guess) you'd use Path.Combine
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1