簡體   English   中英

如何在 web.config 中指定 word 文件和文本文件的擴展名?

[英]how to specify extension for word file and text file in web.config?

我想在 web.config 文件中將 word 文件和文本文件的擴展名作為.doc.txt提供。 我應該在 web.config 中寫什么,最佳實踐是什么。 我是 .net 的新手,請幫助我。

將以下內容添加到您的配置文件中:

<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");
            }

請參考以下鏈接:

http://msdn.microsoft.com/en-us/library/610xe886.aspx

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM