There are many ways to get your current path, unfortunately some of them work for some types of programs but don't work for others. I have tried this one and this one.
I have had to write programs that work in every one of the following types of applications
- Windows applications
- Dll files
- Dll files registered as COM objects
- Windows Services
- Web based applications
- Web services
System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly.Location)
So people should use this instead of anything else.
I have noticed some people make the horrible mistake of mistaking "current directory" with what I have been referring to as "application path". They are VERY different things, current application may change if the user does something like opening his browser and going to c:\foo, the programmer may not notice this since he hasn't opened any folders when he was coding, so be careful of that too
No comments:
Post a Comment