tag:blogger.com,1999:blog-3891346170516717444.post1567926786269765380..comments2023-11-21T19:58:15.115+08:00Comments on Start Coding: Application.StartupPath != Environment.CurrentDirectorygaryhttp://www.blogger.com/profile/14341234358005844724noreply@blogger.comBlogger6125tag:blogger.com,1999:blog-3891346170516717444.post-27851259770572490902018-10-08T13:27:51.285+08:002018-10-08T13:27:51.285+08:00It's a nice post I was really impressed by re... It's a nice post I was really impressed by reading this <b><a href="https://onlineitguru.com/dot-net-online-training-placement.html" title="Dot Net Online Training | .Net Online Course from India | Online IT Guru" rel="nofollow">dOT NET Online Course Hyderabad</a></b>rmouniakhttps://www.blogger.com/profile/06622438005105687926noreply@blogger.comtag:blogger.com,1999:blog-3891346170516717444.post-82633369236739057192010-03-23T17:21:51.158+08:002010-03-23T17:21:51.158+08:00> So, the "Environment.CurrentDirectory&qu...> So, the "Environment.CurrentDirectory" is equivalent to "Application.StartupPath" when running as WinForm/console app and will become variable "%SystemDirectory%" eventually if run under windows service! A lesson learned.<br /><br />This isn't fully correct, even if you run WinForm/console you can run it from directory different from Application.StartupPath, or you can run it from icon, where special property define value of Environment.CurrentDirectory (editable).Garkinhttps://www.blogger.com/profile/09545692837677633543noreply@blogger.comtag:blogger.com,1999:blog-3891346170516717444.post-22184948090466380562009-12-22T19:52:12.531+08:002009-12-22T19:52:12.531+08:00Unmanaged code? I never think of that, haha. Thank...Unmanaged code? I never think of that, haha. Thanks for ur input.garyhttps://www.blogger.com/profile/14341234358005844724noreply@blogger.comtag:blogger.com,1999:blog-3891346170516717444.post-17768401397811912902009-12-04T08:04:11.799+08:002009-12-04T08:04:11.799+08:00Not quite foolproof. Assembly.GetEntryAssembly() d...Not quite foolproof. Assembly.GetEntryAssembly() does not work from Unmanaged code. I had it return null when running unit tests from the IDE. Assembly.GetExecutingAssembly() seemed to work ok though...Unknownhttps://www.blogger.com/profile/16353083531587686213noreply@blogger.comtag:blogger.com,1999:blog-3891346170516717444.post-9985000272332156902008-12-19T11:46:00.000+08:002008-12-19T11:46:00.000+08:00Thanks Dean, though I have already mentioned it in...Thanks Dean, though I have already mentioned it in #p/s(using Assembly class). I really appreciate itgaryhttps://www.blogger.com/profile/14341234358005844724noreply@blogger.comtag:blogger.com,1999:blog-3891346170516717444.post-86993883571530447822008-12-15T13:21:00.000+08:002008-12-15T13:21:00.000+08:00You can also use:Assembly.GetEntryAssembly().Locat...You can also use:<BR/><BR/>Assembly.GetEntryAssembly().Location<BR/><BR/>To get the full path to the executable you're running inside of and the use Path.GetDirectoryName() to get the directory.<BR/><BR/>No extra dependencies and 100% foolproof :-) You can even use Assembly.GetExecutingAssembly().Location if your DLL is not in the same folder as the .exe!Anonymousnoreply@blogger.com