GPWiki.org
GPWiki.org
It is currently Wed Jun 19, 2013 3:12 am

All times are UTC




Post new topic Reply to topic  [ 14 posts ] 
Author Message
PostPosted: Wed Dec 28, 2011 6:04 am 
Grand Optimizer
User avatar

Joined: Mon Jan 17, 2005 6:01 pm
Posts: 353
Location: Canada
So im reading info from a file on startup. Ive placed a copy of the file in \Vs\bin\debug\whatever, and during debugging phase it finds and reads it correctly using Application.StartupPath.

However... When I compile the program and run the executable, Application.StartupPath returns this: (i output it to a debug.txt file just to see)

C:\Documents and Settings\Jimbo\Local Settings\Apps\2.0\X7VBCCL2.VJH\BGHK34JX.CK0\tank..tion_0000000000000000_0001.0000_b7d7452a6e1eee43

Whereas it should return:

C:\Documents and Settings\Jimbo\Desktop\Tankz2

Has anyone seen anything like this before? I was on MSDN and it was saying something about a path being different for a "ClickOnce" Application, that's greek to me.

Any help? Thanks!

_________________
"None are more hopelessly enslaved than those who falsely believe they are free."
"It is no measure of health to be well adjusted to a profoundly sick society."
"Hope is the first step on the road to dissapointment." -Jonah Orion
http://tankzgame.blogspot.com


Top
 Profile  
 
PostPosted: Wed Dec 28, 2011 8:33 pm 
Dexterous Droid
User avatar

Joined: Wed Aug 18, 2004 7:40 pm
Posts: 3746
Location: South Africa
I've never used Application.StartupPath, but just plain old relative addressing hasn't let me down so far, e.g. "./levels/level1.dat". The dot (.) means "current directory". Two dots (..) means "one directory above the current one".

_________________
Whatever the mind can conceive and believe, it can achieve


Top
 Profile  
 
PostPosted: Wed Dec 28, 2011 8:48 pm 
Grand Optimizer
User avatar

Joined: Mon Jan 17, 2005 6:01 pm
Posts: 353
Location: Canada
Im not sure I understand. How do you use this?

_________________
"None are more hopelessly enslaved than those who falsely believe they are free."
"It is no measure of health to be well adjusted to a profoundly sick society."
"Hope is the first step on the road to dissapointment." -Jonah Orion
http://tankzgame.blogspot.com


Top
 Profile  
 
PostPosted: Wed Dec 28, 2011 10:09 pm 
Bibliotherapist
User avatar

Joined: Wed Nov 03, 2004 1:28 pm
Posts: 6751
Location: Oxford, Englandshire
MSDN wrote:
Application.StartupPath Property
.NET Framework 4

Gets the path for the executable file that started the application, not including the executable name.

Property Value
Type: System.String
The path for the executable file that started the application.
This path will be different depending on whether the Windows Forms application is deployed using ClickOnce. ClickOnce applications are stored in a per-user application cache in the C:\Documents and Settings\username directory. For more information, see Accessing Local and Remote Data in ClickOnce Applications.


Seems like if your app is a ClickOnce app, it'll be deployed to and started from a cached location in %username%.

Are you using ClickOnce deployment?

_________________
10 PRINT "Bad Monkey ";
20 GOTO 10


Top
 Profile  
 
PostPosted: Thu Dec 29, 2011 12:03 am 
Grand Optimizer
User avatar

Joined: Mon Jan 17, 2005 6:01 pm
Posts: 353
Location: Canada
Codehead wrote:
Are you using ClickOnce deployment?


That's a terrific question. I have no idea. lol

I thought maybe it was some annoying obscure option somewhere in the IDE, but I haven't found it.

_________________
"None are more hopelessly enslaved than those who falsely believe they are free."
"It is no measure of health to be well adjusted to a profoundly sick society."
"Hope is the first step on the road to dissapointment." -Jonah Orion
http://tankzgame.blogspot.com


Top
 Profile  
 
PostPosted: Thu Dec 29, 2011 1:18 am 
Grand Optimizer
User avatar

Joined: Mon Jan 17, 2005 6:01 pm
Posts: 353
Location: Canada
IGTHORN:

Just tried your method. Again, works during Debugging but the compiled EXE fails to find it.

_________________
"None are more hopelessly enslaved than those who falsely believe they are free."
"It is no measure of health to be well adjusted to a profoundly sick society."
"Hope is the first step on the road to dissapointment." -Jonah Orion
http://tankzgame.blogspot.com


Top
 Profile  
 
PostPosted: Thu Dec 29, 2011 7:26 am 
Dexterous Droid
User avatar

Joined: Wed Aug 18, 2004 7:40 pm
Posts: 3746
Location: South Africa
Hmm, not sure what to make of that.

When you compile your project, do you have an .exe being generated in your /bin folder, but when you run that .exe it thinks that it's located somewhere else?

If the .exe is somewhere in the Local Settings\Apps folder, then for a hacky solution, you could perhaps copy it back to where your data files are and run it from there.

_________________
Whatever the mind can conceive and believe, it can achieve


Top
 Profile  
 
PostPosted: Thu Dec 29, 2011 3:11 pm 
Grand Optimizer
User avatar

Joined: Mon Jan 17, 2005 6:01 pm
Posts: 353
Location: Canada
The uncompiled project files get output to somewhere in my Visual Studio folder. When I debug, it executes from there and looks in the bin\x86\Debug\ folder for the text file.

The compiled EXE sits in a folder on my Desktop. When it runs, its looking in

C:\Documents and Settings\Jimbo\Local Settings\Apps\2.0\X7VBCCL2.VJH\BGHK34JX.CK0\tank..tion_0000000000000000_0001.0000_b7d7453372967c03

Which is a folder that does infact exist on my hard drive, strangely enough. But oubviously this is not where i want the app to be looking for the file.

_________________
"None are more hopelessly enslaved than those who falsely believe they are free."
"It is no measure of health to be well adjusted to a profoundly sick society."
"Hope is the first step on the road to dissapointment." -Jonah Orion
http://tankzgame.blogspot.com


Top
 Profile  
 
PostPosted: Thu Dec 29, 2011 4:00 pm 
Grand Optimizer
User avatar

Joined: Mon Jan 17, 2005 6:01 pm
Posts: 353
Location: Canada
Ok, the problem does seem to be related to ClickOnce.... I think. Im a little fuzzy on what's going on, but from what I can tell, the problem lies in the fact that when the app is being published, it doesnt copy the text file to the wierd folder along with the rest of the files. Im not sure if this has anything to do with an application manifest (which i dont know how to manipulate).

Theres 2 big problems at the moment.

1) I found the "Enable ClickOnce security" box. I disabled it, and it didn't help.

2) Even if the text file DID get copied to that wierd directory, thats still useless because that file is meant to be easily modified by the user - in the game's main folder. It would be retarded to have to go digging into that wierd ClickOnce directory.

Sigh. File I/O used to be so simple.

_________________
"None are more hopelessly enslaved than those who falsely believe they are free."
"It is no measure of health to be well adjusted to a profoundly sick society."
"Hope is the first step on the road to dissapointment." -Jonah Orion
http://tankzgame.blogspot.com


Top
 Profile  
 
PostPosted: Thu Dec 29, 2011 8:31 pm 
Grand Optimizer
User avatar

Joined: Mon Jan 17, 2005 6:01 pm
Posts: 353
Location: Canada
Code:
string text = System.Windows.Forms.Application.LocalUserAppDataPath;
string appPath = Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath);
string outputDir = System.IO.Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath);
string CurrentDir = Directory.GetCurrentDirectory();
string startupPath = System.Windows.Forms.Application.StartupPath;


So far, in addition to the syntax IGTHORN suggested, I've tried all those. And they ALL return the ClickOnce folder. *pulls hair out*

_________________
"None are more hopelessly enslaved than those who falsely believe they are free."
"It is no measure of health to be well adjusted to a profoundly sick society."
"Hope is the first step on the road to dissapointment." -Jonah Orion
http://tankzgame.blogspot.com


Top
 Profile  
 
PostPosted: Thu Dec 29, 2011 10:14 pm 
Bibliotherapist
User avatar

Joined: Wed Nov 03, 2004 1:28 pm
Posts: 6751
Location: Oxford, Englandshire
I had a quick dig around earlier, but couldn't find any way of disabling ClickOnce. There must be something in the project properties.

_________________
10 PRINT "Bad Monkey ";
20 GOTO 10


Top
 Profile  
 
PostPosted: Thu Dec 29, 2011 10:50 pm 
Grand Optimizer
User avatar

Joined: Mon Jan 17, 2005 6:01 pm
Posts: 353
Location: Canada
Codehead wrote:
I had a quick dig around earlier, but couldn't find any way of disabling ClickOnce. There must be something in the project properties.


Thanks, I appreciate the effort! Yeah theres some setting in the IDE that has to do with ClickOnce security. Didn't seem to change anything.
Honestly, im not bothered by ClickOnce.. I just wish i could figure out how to programatically determine the ACTUAL directory of the executable that the user is clicking on.

That seems like it should be easy. lol.

_________________
"None are more hopelessly enslaved than those who falsely believe they are free."
"It is no measure of health to be well adjusted to a profoundly sick society."
"Hope is the first step on the road to dissapointment." -Jonah Orion
http://tankzgame.blogspot.com


Top
 Profile  
 
PostPosted: Sat Dec 31, 2011 12:35 am 
This is what I use in my apps when I need the application startup directory:
AppDomain.CurrentDomain.BaseDirectory


Top
  
 
PostPosted: Sat Dec 31, 2011 1:52 am 
Grand Optimizer
User avatar

Joined: Mon Jan 17, 2005 6:01 pm
Posts: 353
Location: Canada
Andre wrote:
This is what I use in my apps when I need the application startup directory:
AppDomain.CurrentDomain.BaseDirectory


Just tried it. That also returns the ClickOnce directory. Thanks, though!

_________________
"None are more hopelessly enslaved than those who falsely believe they are free."
"It is no measure of health to be well adjusted to a profoundly sick society."
"Hope is the first step on the road to dissapointment." -Jonah Orion
http://tankzgame.blogspot.com


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 14 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group