tags:

views:

530

answers:

1

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;
      }
     }
    }
+3  A: 

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:\email path 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 the find in files command in Visual Studio (ctrl + shift + f) and make sure to specify *.* in the "look at this file types" box.

SECOND EDIT:

Nope, I don't have specified the path anywhere neither in my code nor in configuration files.

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).

Paolo Tedesco
I don't there is any problem with project settings. The problem is that it is looking for the email.config file in a wrong directory and at the directory which it is looking exists only on my development machine.
hab
+1 for the additional effort to explain it to the OP.
Cerebrus
Nope, I don't have specified the path anywhere neither in my code nor in configuration files.
hab
@Cerebrus: what does OP mean?
Paolo Tedesco