Hey I’m using the ExeConfigurationFileMap class’s OpenMappedExeConfiguration method to open a config file. The config file is used by two programs in the same directory.
Everything is working fine on my development machine but when I copied the programs to another machine I get this error while executing the program
Code not find a part of the path D:\email\email.config
The other program can access the email.config file easily. Everything is one directory but the other program is pointing to the old path in my development machine 🙁
Here is a portion of the code which throws the Exception
class Program
{
static readonly string configFileName = "email.config";
static int Main(string[] args)
{
try
{
var configMap = new ExeConfigurationFileMap { ExeConfigFilename = configFileName };
Configuration externalConfig = ConfigurationManager.OpenMappedExeConfiguration(configMap, ConfigurationUserLevel.None);
}
catch (Exception e)
{
Console.WriteLine(e.Message);
return 1;
}
}
}
Have you tried searching your project (configuration files included) for that path? It will be surely written somewhere, you just need to find it…
EDIT: I understood what your problem is, I’m just saying that the
D:\emailpath your program is searching is coming from somewhere in your code or in your configuration files. Just try to search for “D:” in your project; use thefind in filescommand in Visual Studio (ctrl + shift + f) and make sure to specify*.*in the “look at this file types” box.SECOND EDIT:
If you tried searching for the path as I suggested (please do it if you haven’t done it yet) then check the configuration files on the target machine. That path is written somewhere, you juat have to find out where, and for that you must use a tool of some kind (even Windows’s file search should do).