In a C# 2010 console application it work works fine until it gets to a certain spot. Basically this console application calls another console application.
Here is what is happening:
1. When I run the console application, it runs ok until get reeaches a certain point. At that point is it trying to run the second console application from an directory path I had a week ago. Then I get error messages from the second console application.
2. Also it looks like I am the only person who can run this application. The application starts and never continues for other people.
I am thinking my problem must be in some file in the C# 2010 solution file.
Thus can you tell me what I can do to resolve my problem?
Loading
VulpesPosted Oct 21, 2012, 3:19 PM
dcPosted Oct 21, 2012, 7:12 PM
dcPosted Oct 21, 2012, 2:55 PM
I do have the additional questions to ask which are:
1. You mentioned 'storing files at arbitrary absolute locations.' So if I specify a location like the following:
'C:\\allcustomers\country\state\city\customernumber5\app.exe',
this is an arbitrary absolute location corrrect? If not, can you show me what you mean by that statement?
The arbritrary path is a result of not knowing what my current directory path is?
2. I should basically use a directory path like "D:\\allcustomers".
I should put all the executables right under the allcustomers directory level.
3. I should not place the executables in a c:\program files path unless I have a 'systems' reason for using this location?
4. Would a clean and full build solve the problem? If so, can you tell me why?
4. This problem is most likely not caused by a hidden file?
VulpesPosted Oct 21, 2012, 1:10 PM
dcPosted Oct 21, 2012, 11:25 AM
I have the following additional questions to ask you which are the following:
1. Are you saying that if I install the application in the same directory path, this sort of problem will go away? Can you tell me why this would solve my problem?
2. You mentioned that I should use the following code to find the second console application:
string mainPath = System.IOPath.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
string secondPath = mainPaath + "\\" + "second.exe";
Can you tell me why this code this better than using a static value to where the second console application is actually located at?
3. You mentioned the following,
"If, for some reason, you don't want to do that, then I'd install it in one of Windows 'special folders' such as Programs or ProgramFiles. See here for a list of these:
http://msdn.microsoft.com/en-us/library/system.environment.specialfolder.aspx
In the latter case you could then get the path to the second application using this code:
string secondPath = System.Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles) + "\\" + "second.exe";
Can you tell me which method is better and why?
4. Until I saw your answer, I was thinking of copying the code of the first console application to a new solution ide and see if the problem would go away. However according to what I see you are saying this problem would show up again correct?
VulpesPosted Oct 21, 2012, 9:41 AM
http://msdn.microsoft.com/en-us/library/system.environment.specialfolder.aspx
dcPosted Oct 20, 2012, 7:30 PM
I have no idea how the first program calls the second wrong with the wrong directory path. Do I need to keep the path of the second console application static?
Shivanand ArurPosted Oct 20, 2012, 4:50 AM