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

VulpesRank #55 · 29.2K reputationPosted May 26, 2013, 9:25 AM EDT
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.
paul aarman17 reputationPosted May 26, 2013, 11:16 AM EDT
VulpesRank #55 · 29.2K reputationPosted May 26, 2013, 12:42 PM EDT
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 aarman17 reputationPosted May 27, 2013, 9:24 AM EDT
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
VulpesRank #55 · 29.2K reputationPosted May 27, 2013, 10:03 AM EDT
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 aarman17 reputationPosted May 27, 2013, 12:29 PM EDT
what i need is the text inside the file as the string
VulpesRank #55 · 29.2K reputationPosted May 27, 2013, 2:58 PM EDT