As far as I know, the answer is no. It has to be App.config, which will be renamed to "youapp.exe.config" and copied to bin/debug (or bin/release) directory.

解决方案 »

  1.   

    就是楼上说的,IDE默认用App.config,编译的时候自动会根据生成的exe文件来命名。如你的程序是hello.exe,那么IDE会自动在同一目录下生成hello.exe文件。你用其他的ide找不到。
      

  2.   

    ConfigurationSettings.AppSettings只能读取默认的App.config文件名,你可以通过右键点击项目->添加新项->应用程序配置文件添加一个配置文件。
      

  3.   

    就是楼上说的,IDE默认用App.config,编译的时候自动会根据生成的exe文件来命名。如你的程序是hello.exe,那么IDE会自动在同一目录下生成hello.exe文件。你用其他的ide找不到。
    ------------------------------------------------------------------------
    是这样吗?我现在的exe文件名是loader.exe,我希望config文件名是loader.exe.config,但是只能读出App.config的内容。
      

  4.   

    如果你的exe文件名是loader.exe,config文件名是loader.App.config.
      

  5.   

    我现在的exe文件名是loader.exe,我希望config文件名是loader.exe.config
    ---------------------------------------------------你生成exe文件的文件夹内肯定是loader.exe.config
      

  6.   

    如果更改了exe文件名,同时也更改config的文件名,只要一致就可以。
      

  7.   

    楼上的几位大哥,我现在的exe文件名就是loader.exe,但是就只认App.config,太奇怪了。况且IDE生成的config文件不在exe文件的文件夹内,而在该工程的目录下。
      

  8.   

    private string appPath = Application.ExecutablePath+".config";
    private XmlDocument configData=new XmlDocument();
    private string GetAppValue(string key)
    {
    return configData.SelectSingleNode("/configuration/appSettings/add[@key='"+key+"']").Attributes["value"].Value;
    }========================
    strText=GetAppValue("date")
    ===========================
    app.config必须在源码目录下,在ide里用添加方式加入<?xml version="1.0" encoding="utf-8" ?>
    <configuration>
    <appSettings>
    <!-- head -->
    <add key="date" value="[06.16]" />
    <add key="department" value="[EPOP]" />
             </appSettings>
    </configuration>
      

  9.   

    我一开始就说过了(第一帖,呵呵),流程是这样的: 假设你的Project叫Foobar,位于E:\Foobar,App.config是在你Project的目录下,就是E:\Foobar。Visual Studio在编译完成后会把这个文件重命名为Foobar.exe.config,然后copy到E:\Foobar\bin\Debug(或Release),Foobar.exe运行的时候,实际使用的是Foobar.exe.config。不信的话,你可以在编译结束后,用notepad打开Foobar.exe.config,改动一下里面的内容,再运行一下Foobar.exe看看。