2012-11-06 8 views
6

F#スクリプト(fsx)ファイルのapp.configファイルを使用できますか?もしそうなら、どうですか?ファイルはどこに置くのですか?fsxファイルのapp.configを使用

+3

はすでにここに答えた:http://stackoverflow.com/questions/645622/app-config-and-f-interactive-not-working –

答えて

0

@JoeBによるリンクされた質問は、F#Interactiveの.fsxスクリプトより適した2つの回答を提供します。

<configuration> 
    <appSettings> 
     <add key="foo" value="bar"/> 
    </appSettings> 
</configuration> 

読むfooこのように:このapp.configファイルに考える

:私は以下のF#スクリプトに適したソリューションを提供

let appConfigPath = System.IO.Path.Combine(Directory.GetCurrentDirectory(), "app.config") 
let fileMap = ExeConfigurationFileMap() 
fileMap.ExeConfigFilename <- appConfigPath 
let config = ConfigurationManager.OpenMappedExeConfiguration(fileMap, ConfigurationUserLevel.None) 
let foo = config.AppSettings.Settings.["foo"].Value 
Console.WriteLine(foo) 
関連する問題