3
我想在web.config文件中爲word文件和文本文件擴展名爲.doc
和.txt
。 哪裏在web.config我應該寫什麼是最佳實踐。我是.net新手請幫助我。如何在web.config中爲word文件和文本文件指定擴展名?
我想在web.config文件中爲word文件和文本文件擴展名爲.doc
和.txt
。 哪裏在web.config我應該寫什麼是最佳實踐。我是.net新手請幫助我。如何在web.config中爲word文件和文本文件指定擴展名?
以下內容添加到您的配置文件:
<appSettings>
<add key="FileExtension" value="docx"/>
</appSettings>
然後,您可以讀取它通過以下方式:
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");
}
請參考以下鏈接: