10 Replies - 972 Views - Last Post: 07 May 2015 - 01:14 PM Rate Topic: -----

#1 elfenliedtopfan5   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 15
  • Joined: 21-April 15

c# find directory and save its path

Posted 07 May 2015 - 08:31 AM

ok what im trying to do and confused in what it would be called so if this is wrong please tell me and im sorry if its explained wrong what i want to do is have a open file dialog to find a folder on your pc basically im making / improving world at war zombies launcher for mod tools and stuff and what i want to do is for the user to search for there mod tools folder then once thats found my program goes off that path like say for example:

C:\Program Files (x86)\Activision\Call of Duty - World at War\mods\corpse_party\maps\_zombiemode.gsc


so if i told the user to find

C:\Program Files (x86)\Activision\Call of Duty - World at War\mods\corpse_party
it will save that directory each time they start up the program and then i can make code going from there mods folder because inside the mods folder it has all the stuff i need to access for launcher but im not sure how i would get the program to look for that folder and then link to it so for another example

what i want to do here is for them to find there mod tools folder and zombiemode.gsc and all others are found in
C:\Program Files (x86)\Activision\Call of Duty - World at War\mods\corpse_party\maps\_zombiemode.gsc

Posted Image

but if i released my program like this not evrey person installs world at war on c drive and does not have a mod folder called corpse party and im lost on how to get a derict saved link to there mod folder by using file dialog

i hope i make cents as i am dyslexic and have trouble explaining things

thanks in advance
elfenliedtopfan5

Is This A Good Question/Topic? 0
  • +

Replies To: c# find directory and save its path

#2 modi123_1   User is offline

  • Suitor #2
  • member icon



Reputation: 15260
  • View blog
  • Posts: 61,140
  • Joined: 12-June 08

Re: c# find directory and save its path

Posted 07 May 2015 - 08:37 AM

Eeesh. That is not a pretty looking interface.

Directories are just tress, right? You can iterate through a tree with a loop.. I would imagine the 'io.directories.get directories' would be of use.
https://msdn.microso...=vs.110%29.aspx

Alternatively the 'file picker' dialog control can just let the user do the searching.
Was This Post Helpful? 0
  • +
  • -

#3 tlhIn`toq   User is offline

  • Xamarin Cert. Dev.
  • member icon

Reputation: 6535
  • View blog
  • Posts: 14,450
  • Joined: 02-June 10

Re: c# find directory and save its path

Posted 07 May 2015 - 08:57 AM

View Postmodi123_1, on 07 May 2015 - 09:37 AM, said:

Eeesh. That is not a pretty looking interface.

*Fugly*

Quote

ok what im trying to do and confused in what it would be called so if this is wrong please tell me and im sorry if its explained wrong what i want to do is have a open file dialog to find a folder on your pc basically im making / improving world at war zombies launcher for mod tools and stuff and what i want to do is for the user to search for there mod tools folder then once thats found my program goes off that path like say for example:

Fella, its called 'punctuation'. Look it up. I really try to not be the grammar police but after a certain point it just becomes a STRUGGLE to even understand what you're saying. If we can't grasp what you're saying, doing or having trouble with then we can't help you. At least make an effort to meet us someplace around an 8th grade reading level where you use punctuation and don't make entire paragraphs one giant run-on sentence.

Quote

as i am dyslexic and have trouble explaining things

Maybe I don't understand the condition of 'dyslexia', but I don't think it accounts for being too lazy to capitalize "I" or to break up your sentences. It might, might, account for 'derict' but even that just seems like either ebonics or SMS.

I am sympathetic to difficulty reading/writing. But I don't think its an excuse to not gather your thoughts. Go ahead and misspell your explanations 100 different ways, but you can stop, think, plan and list before banging on the keyboard or hitting [send]. Gathering your thoughts is VITAL if you are going to plan out the program design. You HAVE to stop, plan, make a list, make a plan for your program before you start typing the first line of code. Apply that same thinking to your posts.

After reading your post several times I only find one question/problem. Tell me if I missed something:

Quote

if i released my program like this not evrey person installs world at war on c drive and does not have a mod folder called corpse party and im lost on how to get a derict saved link to there mod folder by using file dialog

So your issue is that you want your program to look for the game's directory. That way when the user opens the OpenFileDialog it will default to that directory. Is that your question: How to find the directory the game\mod\settings installed to?

Clearly you know a lot about the game or you wouldn't be trying to modify it. So how does the game now where this location is? Is there a registry setting? Is there a settings file in the user's application support directory?

This post has been edited by tlhIn`toq: 07 May 2015 - 08:58 AM

Was This Post Helpful? 0
  • +
  • -

#4 elfenliedtopfan5   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 15
  • Joined: 21-April 15

Re: c# find directory and save its path

Posted 07 May 2015 - 08:59 AM

View Postmodi123_1, on 07 May 2015 - 08:37 AM, said:

Eeesh. That is not a pretty looking interface.

Directories are just tress, right? You can iterate through a tree with a loop.. I would imagine the 'io.directories.get directories' would be of use.
https://msdn.microso...=vs.110%29.aspx

Alternatively the 'file picker' dialog control can just let the user do the searching.


i know interface does not look good it was for a friend that begged i changed the whole lot to green for him so i did and not changed it back yet i will not release it like that and thank you for your reply :)
Was This Post Helpful? 0
  • +
  • -

#5 Skydiver   User is offline

  • Code herder
  • member icon

Reputation: 7052
  • View blog
  • Posts: 23,972
  • Joined: 05-May 12

Re: c# find directory and save its path

Posted 07 May 2015 - 09:01 AM

Or you could use Product.InstallProperty(INSTALLPROPERTY_INSTALLLOCATION), but you'll have to go through the (steep) learning curve of using the Windows Installer APIs, as well as learning how to use COM InterOp.
Was This Post Helpful? 0
  • +
  • -

#6 tlhIn`toq   User is offline

  • Xamarin Cert. Dev.
  • member icon

Reputation: 6535
  • View blog
  • Posts: 14,450
  • Joined: 02-June 10

Re: c# find directory and save its path

Posted 07 May 2015 - 09:11 AM

View Postelfenliedtopfan5, on 07 May 2015 - 09:59 AM, said:

i know interface does not look good it was for a friend that begged i changed the whole lot to green for him so i did and not changed it back yet i will not release it like that and thank you for your reply :)/>


User preferences.

Give the program some settings for this. Let the user set their colors.
  • Background Color
  • Text Color
  • Border/Accent Color


Or at the very least define some themes. Visual Studio let's you pick 'Dark', 'Light', 'Blue' for example.
Was This Post Helpful? 0
  • +
  • -

#7 modi123_1   User is offline

  • Suitor #2
  • member icon



Reputation: 15260
  • View blog
  • Posts: 61,140
  • Joined: 12-June 08

Re: c# find directory and save its path

Posted 07 May 2015 - 09:13 AM

No, tlhnin tlhIn`toq, is wrong. That is not a good option. The theme should be black and white, eye burning lime, or hotdog stand.

This post has been edited by tlhIn`toq: 07 May 2015 - 09:57 AM
Reason for edit:: Name misspelled

Was This Post Helpful? 0
  • +
  • -

#8 elfenliedtopfan5   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 15
  • Joined: 21-April 15

Re: c# find directory and save its path

Posted 07 May 2015 - 09:22 AM

@tlhIn`toq
mod: removed giant quote

the code for the launcher was given to me by treyarch , And to response to your reply yes that is exactly what i want to do i want it to default there so then i could add buttons ect, and when i press them its not active to just my mods folder as it currently would throw a error if I released it as it defaults to the above link to the game file but that's only where i have installed it

some people like my friend has installed the game on the f drive of his pc witch would mess my program up and i'm sorry about not having good grammar ;(

This post has been edited by modi123_1: 07 May 2015 - 09:24 AM
Reason for edit:: let's not quote giant posts above yours

Was This Post Helpful? 0
  • +
  • -

#9 tlhIn`toq   User is offline

  • Xamarin Cert. Dev.
  • member icon

Reputation: 6535
  • View blog
  • Posts: 14,450
  • Joined: 02-June 10

Re: c# find directory and save its path

Posted 07 May 2015 - 10:09 AM

If your program throws errors (for any reason) its because you aren't validating data. You have to write robust code. Just because the user says "Use this folder" doesn't mean the folder even exists. Or that because it did exist last week doesn't mean it exists now. Your code has to check that files and folders exists, presume failure and expect it. Its your responsibility to write robust code.

I'm still not following what your actual question is though.

You want your code to search the hard drive for a mod's directory, then save that path in its settings. Is that right?
So what, exactly, is the problem? How to search the drive? How to save the settings?

I'm going to assume you aren't lazy. So you've already done a Google search for "C# Search Harddrive". Right? That would have gotten you lots of examples. Which ones did you try? Show us your search code and tell us what errors you got.
Was This Post Helpful? 0
  • +
  • -

#10 elfenliedtopfan5   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 15
  • Joined: 21-April 15

Re: c# find directory and save its path

Posted 07 May 2015 - 11:29 AM

well i currently had this only issue is i don't know how to get it to look for files believe me i do look and search on google before posting tho like you said i don't explain things well so i'm really going to try now

right i want to make a button on form witch i done and given this code

// make a fake file to save
            string dummyFileName = "Save Me In Your Mods";

            SaveFileDialog sf = new SaveFileDialog();
            // make the dummy file feed to the save file dialog
            sf.FileName = dummyFileName;

            if (sf.ShowDialog() == DialogResult.OK)
            {
                // now make it save the path
                string savePath = Path.GetDirectoryName(sf.FileName);
                

witch I made and saves a dummy file and then saves the path well I think it does im quite new to this
and then form there I want it to search the folder where it got saved for the following
zombiemode.gsc
zombiemode_weapons.gsc
dlc3_code.gsc
and _loadout.gsc

if it finds them it will enable buttons that I have on form if it don't find them it leaves them grayed out aka disabled

but I would like it to save the location and keep in the programs memory so each time program is lanched it remembers the location it has previously found ( and in response to your reply when you mod for this game you cant change its location or the program messes up anyway without it being modded so once its in the mods folder the mod and mod name dont change ).

This post has been edited by andrewsw: 07 May 2015 - 01:43 PM
Reason for edit:: Removed previous quote, just press REPLY

Was This Post Helpful? 0
  • +
  • -

#11 tlhIn`toq   User is offline

  • Xamarin Cert. Dev.
  • member icon

Reputation: 6535
  • View blog
  • Posts: 14,450
  • Joined: 02-June 10

Re: c# find directory and save its path

Posted 07 May 2015 - 01:14 PM

Quote

i don't know how to get it to look for files
Well... Have you tried? I have given you a link for a Google search that has lots of examples. But I haven't seen any of your code where you've tried. All you've shown us is some code for the OpenFileDialog. Please show us the code where you've tried to do a search.

Also... Stop telling us "I will have it do A and B and C and D and E and F and G..." we don't need to hear all your plans and dreams for 20 features and behaviors. It muddies the waters of trying to understand the ONE THING you are working on right now that is giving you trouble.

Right now I think you're saying you have 1 actual problem:
  • How to save the directory path the user picked?

Everything else you're saying sounds like plans/behaviors you're eventually going to get to. (IE: It will do this, and this, and this, and this, and this, and this, and this)

Quote

but I would like it to save the location and keep in the programs memory so each time program is launched it remembers the location
Ummmm... In its memory?? When the program closes there is no memory to speak of. You have to save all your settings to a file when you close, then load all your settings again when the program opens. That is how the program 'knows' things between launches.

See FAQ 13: How do I save my settings/values.

TOP most asked:
What does this error message mean?
FAQ 2: How do I debug
FAQ 6: How do I make Class1/Form1 talk to Class2/Form2


FAQ (Frequently Asked Questions - Updated March 2015
Spoiler

This post has been edited by tlhIn`toq: 07 May 2015 - 01:15 PM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1