2011-07-14 30 views
4

私はapp.configにカスタムセクションを保存しようとしています。これは今まで私が持っているコードです:カスタム設定セクションをapp.configに保存できません

  Configuration configuration =  ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); 

      //Read the TunnelSection from the configuration file 
      TunnelSection tunnels = ConfigurationManager.GetSection("TunnelSection") as TunnelSection; 


      HostConfigElement newhost = new HostConfigElement(); 

      newhost.Password = "hola"; 
      newhost.SSHPort = 22; 
      newhost.SSHServerHostname = "holahola"; 

      TunnelConfigElement newtunnel = new TunnelConfigElement(); 

      newtunnel.LocalPort = 12; 
      newtunnel.RemotePort = 12; 
      newtunnel.Name = "12"; 
      newtunnel.DestinationServer = "12"; 

      TunnelCollection newtunnelcollection = new TunnelCollection(); 

      newtunnelcollection.Add(newtunnel); 

      newhost.Tunnels = newtunnelcollection; 

      tunnels.Tunnels.Add(newhost);    

      ConfigurationManager.RefreshSection("TunnelSection"); 

      configuration.Save(ConfigurationSaveMode.Full); 

設定ファイルが変更されていないという問題があります。 TunnelSectionをループすると、新しいホストが追加されたことがわかります。

configuration.AppSettings.Settings.Add("hola", "hola"); 

と、これは正常に動作します:アクセス許可の問題を除外するために

は、私はこのようなのAppSettingsに設定を追加してみました。

私もsaveasを試しましたが、役に立たなかったです。

アイデア? TIA

答えて

1

システム設定は変更できませんが、ユーザー設定を変更することはできます。ユーザー設定はアプリケーションディレクトリには保存されませんが、/ appData //の下に保存されます。その場所で確認してください

+0

appdataはどこにあるのでしょうか?これはウェブアプリケーションでも、決してインストールされていません。これまでのコンソールアプリ。 – yomismo

+0

urプロフィールの下にある – hungryMind

+0

フォルダーなぜそれがそこにありますか?これは私が今Visual Studioで動作しているカスタムアプリケーションです。どこにもインストールされていません。 とにかく私は検索しましたが、そこにはありません。 – yomismo

関連する問題