I am creating an application that needs to load an assembly dynamically from the bin-folder of the application. This is not as straight forward as one might think.
So I tried the following:
string s1 = Directory.GetCurrentDirectory();
string s2 = Environment.CurrentDirectory;
string s3 = Assembly.GetExecutingAssembly().Location;
string s4 = new DirectoryInfo("~/bin").FullName;
string s5 = new DirectoryInfo("/bin").FullName;
string s6 = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
string s7 = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
string s8 = Path.GetDirectoryName(Assembly.GetExecutingAssembly().CodeBase);
Results:
s1 = s2 = “C:\Windows\system32”
s3 = "C:\\WINDOWS\\Microsoft.NET\\Framework\\v2.0.50727\\Temporary ASP.NET Files\\root\\101551d3\\93890f66\\assembly\\dl3\\f2069ce7\\fe4f0aea_dc32ca01\\MyAssemblyName.DLL"
s4 = "C:\\WINDOWS\\system32\\~\\bin"
s5 = "C:\\bin"
s6 = "C:\\Documents and Settings\\MyMachineName\\ASPNET\\Local Settings\\Application Data" (getting desperate, I know)
s7 = "C:\\Documents and Settings\\MyMachineName\\ASPNET\\Application Data"
Finally found one that worked:
No comments:
Post a Comment