| View previous topic :: View next topic |
| Author |
Message |
Stylo Grandmaster Cheater Supreme
Reputation: 3
Joined: 16 May 2007 Posts: 1073 Location: Israel
|
Posted: Fri Nov 09, 2007 1:18 am Post subject: [Question] in C# |
|
|
well.. sometime when i'm doing some programs that checking if some file is exist in some location i'm doing in the Main method the searching
but it's taking very large space and i wanna do it in other method that comes before the Main method and i want that method will return me the location of the file for exemple:
to search gta at drivers: C,D,E
what i do is
| Code: |
File.Exist("<path at C>");
File.Exist("<path at D>");
File.Exist("<path at E>");
|
and after that i'm asking about them and if one of the is true it says he found GTA at the exect Driver.. how do i do it in method that return the location instad of doing it in the Main method?
some1 please?[/code]
_________________
Stylo |
|
| Back to top |
|
 |
Pseudo Xero I post too much
Reputation: 0
Joined: 16 Feb 2007 Posts: 2607
|
Posted: Fri Nov 09, 2007 1:51 am Post subject: |
|
|
Well, I don't know any other methods than using System.IO;
but why don't you use the '%HOMEDRIVE%' variable, instead of trying different drive letters?
_________________
| haxory' wrote: | can't VB do anything??
windows is programmed using VB right? correct me if im wrong.
so all things in windows you have like the start menu is a windows form too. |
|
|
| Back to top |
|
 |
Stylo Grandmaster Cheater Supreme
Reputation: 3
Joined: 16 May 2007 Posts: 1073 Location: Israel
|
Posted: Fri Nov 09, 2007 2:27 am Post subject: |
|
|
what do u mean by '%HOMEDRIVE%'?
i didnt understand what does it do?
_________________
Stylo |
|
| Back to top |
|
 |
Pseudo Xero I post too much
Reputation: 0
Joined: 16 Feb 2007 Posts: 2607
|
Posted: Fri Nov 09, 2007 2:33 am Post subject: |
|
|
| 1qaz wrote: | what do u mean by '%HOMEDRIVE%'?
i didnt understand what does it do? |
Actually, the 'Program Files' variable would do.
Though it's not good to hardcode it.
| Code: | if (System.IO.File.Exists("%PROGRAMFILES%\\Rockstar Games\\GTA San Andreas") == true)
{
MessageBox.Show("GTA SA was found.", this.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
{
MessageBox.Show("GTA SA was not found.", this.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information);
} |
By the way, the use of double slashes was intentional.
_________________
| haxory' wrote: | can't VB do anything??
windows is programmed using VB right? correct me if im wrong.
so all things in windows you have like the start menu is a windows form too. |
|
|
| Back to top |
|
 |
Stylo Grandmaster Cheater Supreme
Reputation: 3
Joined: 16 May 2007 Posts: 1073 Location: Israel
|
Posted: Fri Nov 09, 2007 2:49 am Post subject: |
|
|
but when i write %PROGRAMFILES% it searches in all drivers or just in driver C???
and other thing i asked about how can i bring this location / information about location in the name of the method how can i do it?
_________________
Stylo |
|
| Back to top |
|
 |
Pseudo Xero I post too much
Reputation: 0
Joined: 16 Feb 2007 Posts: 2607
|
Posted: Fri Nov 09, 2007 2:52 am Post subject: |
|
|
| 1qaz wrote: | but when i write %PROGRAMFILES% it searches in all drivers or just in driver C???
and other thing i asked about how can i bring this location / information about location in the name of the method how can i do it? |
'%PROGRAMFILES%' is a replacement for writing 'C:\Program Files' (Except, it works for all drive letters.) So there's no need to try searching for the file in C, D, E, Etc.
_________________
| haxory' wrote: | can't VB do anything??
windows is programmed using VB right? correct me if im wrong.
so all things in windows you have like the start menu is a windows form too. |
|
|
| Back to top |
|
 |
Stylo Grandmaster Cheater Supreme
Reputation: 3
Joined: 16 May 2007 Posts: 1073 Location: Israel
|
Posted: Fri Nov 09, 2007 2:55 am Post subject: |
|
|
well it's still says he didnt find the expect file :/
_________________
Stylo |
|
| Back to top |
|
 |
Noodlez <3
Reputation: 1
Joined: 27 Oct 2007 Posts: 744 Location: Hyrule
|
Posted: Fri Nov 09, 2007 4:25 am Post subject: |
|
|
| Soz cant help But umm Iqaz may have it covered
|
|
| Back to top |
|
 |
samuri25404 Grandmaster Cheater
Reputation: 7
Joined: 04 May 2007 Posts: 955 Location: Why do you care?
|
Posted: Fri Nov 09, 2007 6:20 am Post subject: |
|
|
That's cool; I didn't realize you could use those variables in C#.
Back on topic, I think Xenephobe has it covered.
Though, you might ask the user to input the path for his GTA thing.
|
|
| Back to top |
|
 |
Stylo Grandmaster Cheater Supreme
Reputation: 3
Joined: 16 May 2007 Posts: 1073 Location: Israel
|
|
| Back to top |
|
 |
atom0s Moderator
Reputation: 205
Joined: 25 Jan 2006 Posts: 8587 Location: 127.0.0.1
|
|
| Back to top |
|
 |
|