在下面的代码中,我试图将数组分配给Filepaths
变量m_settings
,但Filepaths
在 LINQ 方法之外无法识别。如何将 的内容存储在FilePaths
我可以在SolveInstance
方法中使用的变量中?
public void ShowSettingsGui()
{
var dialog = new OpenFileDialog()
{
Multiselect = true,
Filter = "Data Sources (*.ini)|*.ini*|All Files|*.*"
};
if (dialog.ShowDialog() != DialogResult.OK) return;
var paths = dialog.FileNames;
var FilePaths = paths.ToDictionary(filePath => filePath, File.ReadAllText);
}
private string[] m_settings = Filepaths;
protected override void SolveInstance(IGH_DataAccess DA)
{
if (m_settings == null)
{
AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "You must declare some valid settings");
return;
}
DA.SetData(0, m_settings);
}