[英]how to specify extension for word file and text file in web.config?
i want to give extensions for word file and text file as .doc
and .txt
in web.config file.我想在 web.config 文件中将 word 文件和文本文件的扩展名作为
.doc
和.txt
提供。 where in web.config should i write and what is the best practice.我应该在 web.config 中写什么,最佳实践是什么。 I am new to .net please Help me.
我是 .net 的新手,请帮助我。
Add the following to your config file:将以下内容添加到您的配置文件中:
<appSettings>
<add key="FileExtension" value="docx"/>
</appSettings>
Then, you can read it the following way:然后,您可以通过以下方式阅读它:
System.Configuration.Configuration rootWebConfig1 =
System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration(null);
if (rootWebConfig1.AppSettings.Settings.Count > 0)
{
System.Configuration.KeyValueConfigurationElement customSetting =
rootWebConfig1.AppSettings.Settings["customsetting1"];
if (customSetting != null)
Console.WriteLine("customsetting1 application string = \"{0}\"",
customSetting.Value);
else
Console.WriteLine("No customsetting1 application string");
}
Refer to the following link:请参考以下链接:
http://msdn.microsoft.com/en-us/library/610xe886.aspx http://msdn.microsoft.com/en-us/library/610xe886.aspx
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.