i added my app in regedit in the auto lunch folder
where skype by example is to auto lunch
when my app is started this way it crash at startup
the debuger states that theres a missing part of the path of a certain file
yet when i start my app normaly it all works even that file works
any idea on what could cause this auto startup to crash my app
Loading
VulpesPosted May 27, 2013, 6:58 PM
paul aarmanPosted May 27, 2013, 4:29 PM
what i need is the text inside the file as the string
VulpesPosted May 27, 2013, 2:03 PM
It depends on whether the file will always be at an absolute location within the file system or whether it will be at the same location relative to the app itself.
In the former case, you have to specify the absolute path to the file.
In the latter case, there are various approaches depending on what type of application it is.
If it's windows forms app you could use:
string filePath = Application.StartupPath + @"\values\Your-Room-Here.txt";
Otherwise you could use:
paul aarmanPosted May 27, 2013, 1:24 PM
string textfile= File.ReadAllText(@"values\Your-Room-Here.txt");
this is the exact line when the app is run normaly its all good
but at startup it trys to find the file in c:/win32/
i need the file to be located in the way it is now for the app to run from anywhere
anyway to fix this
VulpesPosted May 26, 2013, 4:42 PM
string text = File.ReadAllText("somefile.txt");
the current directory would be searched for somefile.txt as a full path is not specified. A full path would be something like c:\mydocuments\somefile.txt.
I wondered whether this might explain why the file couldn't be found when the app is started from the auto launch folder?
paul aarmanPosted May 26, 2013, 3:16 PM
VulpesPosted May 26, 2013, 1:25 PM
However, when the app is started using auto launch you will need to specify the full path as the start-up folder will be different.