【发布时间】:2011-07-14 21:46:15
【问题描述】:
有没有办法在不使用“File.Exists”的情况下找出 app.config 文件是否存在? 我试过了
if ( !ConfigurationManager.ConnectionStrings.ElementInformation.IsPresent )
{...}
但即使存在带有连接字符串的 app.config,IsPresent 也是 false。
编辑: 我是否误解了 IsPresent 属性?
【问题讨论】:
-
File.Exist有什么问题? -
使用类似“ConfigurationManager.IsPresent”而不是“System.IO.File.Exists(System.Reflection.Assembly.GetEntryAssembly().Location + “.config”的代码会更简洁)"
标签: c# app-config