I have two Windows Application projects and i need to use Application.StartupPath() to read from some files. Build output [in Project Properties] for both projects is set to bin\Release. Still, for Project A the executable is created in bin\Debug so Application.StartupPath() points to bin\Debug. But every time i compile Project B, the executable is created in bin\Release [so Application.StartupPath() poinst to bin\Release], but there is another executable in bin\Debug that at some compiles gets updated. It seems to be a random behaviour. Or am I missing another setting? I need to be able to know exactly where my output will be created.

thank you
p.s. That's how Project B behaves on a vista machine. But on an XP machine Application.StartupPath() sometimes points to bin\Debug, and other times to bin\Release. :-??

It sounds like your solutions file isn't being saved by the IDE. What you could do for development is something like:

public static string GetFileName()
    {
#if (DEBUG1)
      return @"C:\blah.txt"; //dont need to use App.Path()
#else
      return System.IO.Path.Combine(System.Windows.Forms.Application.StartupPath, "blah.txt");
#endif
    }
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.