Why is my program executing from a temporary folder ?
-
Wednesday, March 28, 2012 1:22 PM
As VS2010 Express will not create a Project deployment for me, I am having to write my own, how hard can it be, I thought ......... a long time ago !!!
Basically I am running into one problem that I cannot find a way around. When I copy my Setup project from this PC to another & I execute the Setup.exe program, one of the first things that I do is to ascertain the path of the executing Setup program, in order to access the Folder it is in & the other files that I am deploying, including the main C# Program.
I do this by simply using one of the following lines of code :
//string myPath = Path.GetDirectoryName(Application.ExecutablePath); //string myPath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().CodeBase); string myPath = Application.StartupPath;
All of them work on this machine when running in Debug mode.
However, having tried to run the Setup on a WinXP laptop, a Windows 7 laptop and a Server running Windows Server Standard and getting nowhere, I am at my wit's end. I have put a MessageBox.Show command right at the top of the program to show me the path of the executing Setup.exe program (i.e. the Folder from where I clicked on it to start it running), where it should be D:\KAELC on the winXP maching, E:\KAELC on the Windows 7 machine and C:\Users\Administrator\Desktop\KAELC on the Server. It is never as expected, it is always on a temporary Folder deep within Users (or Documents and Settings) \Appdata\Local\Apps\2.0\abcde\fghij\klmno !!!
Why is it doing this ? Why is it not executing from where I am actually executing it ?!? At the very least, how can I pick up the REAL Folder, so that I can point the rest of the program at the right place, not at this nonsense place ?!?
All Replies
-
Friday, March 30, 2012 6:07 AMModerator
Hi vodkasoda,
It seems that your execute root directory is this place. Perhaps you open your specified project within this folder so that it will map your current directory to this folder as my understanding.
I hope it helps you.
Sincerely,
Jason Wang
Jason Wang [MSFT]
MSDN Community Support | Feedback to us
- Marked As Answer by Jason Dot WangMicrosoft Contingent Staff, Moderator Wednesday, April 11, 2012 5:03 AM
- Unmarked As Answer by Jason Dot WangMicrosoft Contingent Staff, Moderator Friday, April 27, 2012 2:12 AM
-
Friday, March 30, 2012 11:00 AM
Jason, thanks for answering, but I don't really understand what you mean !!!
I started a new thread when I'd found out a bit more, but still nobody can help and I don't understand what's going on ... please take a look here, at this thread, that has some pictures showing exactly what is happening ...
http://social.msdn.microsoft.com/Forums/en-US/Vsexpressvcs/thread/3344330d-a250-4d9b-ad06-1c63bc000244
Maybe I am explaining things wrong, all I want to do is to be able to (from my C# program) access the data that I pass to the new machine, so I need to know the path & directory of where that data is ...
-
Wednesday, April 11, 2012 6:57 AM
I see that this question has been marked as having been correctly answered, but that is not the case. Anybody who has a similar problem and consequently finds this thread, will not be able to solve the problem from this answer, which is why I asked for it to be explained !!!
I fully understand the need to regulate the forum and to keep things "tidy", but marking unanswered questions as "answered" is just plain wrong in my book !!!

