Application names, paths and urls have been renamed to 'MyApp' and 'example' just for easier reading.
Hello, I currently use 1 dll file for my application and that is log4net in c#. Now I include my dll in references from
C:\Users\ashle\AppData\Roaming\MyApp
Simply because I will be publicly releasing my application. Now it works fine outside debug mode and inside, but when I run the exe outside the /bin/debug folder it throws an error..
Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'log4net, Version=1.2.15.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a' or one of its dependencies. The system cannot find the file specified. at MyApp.Program.Main(String[] args)
I have also put this code in which I thought would stop it happening.. but what am I doing wrong? this code should cover my a**
if (!Directory.Exists(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "/MyApp"))
{
Console.WriteLine("Created directory: " + Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "/MyApp");
Directory.CreateDirectory(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "/MyApp");
}
if (!File.Exists(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "/MyApp/log4net.dll"))
{
Console.WriteLine("Please wait while we download some files...");
string downloadUrl = "http://example.com";
if (checkWebsiteAvalibility(downloadUrl))
{
WebClient webClient = new WebClient();
webClient.DownloadFileAsync(new Uri(downloadUrl + "/downloads/log4net.dll"),
Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "/MyApp/log4net.dll");
Console.Clear();
But when running the exe solo outside /bin/debug it doesn't even display the "Please wait while we download some files..." line