【发布时间】:2013-07-04 14:57:53
【问题描述】:
我必须以App.config 访问应用程序配置文件名
MailSettingsSectionGroup mailSettings =App.GetSectionGroup("system.net/mailSettings") as MailSettingsSectionGroup;
if (mailSettings != null)
{
FromMail = mailSettings.Smtp.Network.UserName;
password = mailSettings.Smtp.Network.Password;
}
应用配置文件为
<system.net>
<mailSettings>
<smtp from="abc@email.com">
<network host="smtp.server.com" port="587" userName="abc@email.com" password="password" enableSsl="true" />
</smtp>
</mailSettings>
</system.net>
当我以这种方式访问时。它表明应用程序在以下上下文中不存在。请帮助。
【问题讨论】:
-
那是我错过了声明,但我已经在网上搜索过了。如何申报?
标签: c# winforms app-config