i have a bizzare issue with a program ive written where the command File.Exists() doesnt allways detect the same file in the same directory as the executable.
i have somthing like:
if (File.Exists("TextFile1.txt"))
{
//do some stuff
}
but the odd thing is if i run this executable in the cmd prompt it doesnt detect the file. BUT if i start this executable via another process it will detect the File Fine.
Any ideas on this bizzare issue?
Thanks.
Since you’re using a relative path I have a hunch that the location of the executing assembly is not what you think it is.
In your code try checking where the exe was launched from with:
(from http://msdn.microsoft.com/en-us/library/aa457089.aspx)