ASP.NET Web 服务应用程序中 INI 文件的保存位置

发布于 2024-11-01 03:17:57 字数 1252 浏览 2 评论 0原文

我编写了一个Web服务应用程序,因为我创建了一个INI文件来保存所需的所有服务器URL,但是每当我要访问INI文件时我都无法访问该INI文件它会向我显示此错误,

System.IO.FileNotFoundException: Could not find file 'c:\windows\system32\inetsrv\default.ini'.
   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)
   at System.IO.StreamReader..ctor(String path, Encoding encoding, Boolean detectEncodingFromByteOrderMarks, Int32 bufferSize)
   at System.IO.StreamReader..ctor(String path)
   at DARDMeatInspection.services.QABMeatInspectionService.ReadINI() in D:\DARD\trunk\server\DARDMeatInspection\DARDMeatInspection\services\QABMeatInspectionService.asmx.cs:line 116
   at DARDMeatInspection.services.QABMeatInspectionService.GetAllClassifiers() in D:\DARD\trunk\server\DARDMeatInspection\DARDMeatInspection\services\QABMeatInspectionService.asmx.cs:line 27

另外,部署后是否可以更改INI文件的内容? 如果我错了请纠正我。任何帮助将不胜感激。

I have written a web service application, in that I have created an INI file in order to save all the server URLs required, but I couldn't access that INI file whenever I am going to access INI file It will show me this error,

System.IO.FileNotFoundException: Could not find file 'c:\windows\system32\inetsrv\default.ini'.
   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)
   at System.IO.StreamReader..ctor(String path, Encoding encoding, Boolean detectEncodingFromByteOrderMarks, Int32 bufferSize)
   at System.IO.StreamReader..ctor(String path)
   at DARDMeatInspection.services.QABMeatInspectionService.ReadINI() in D:\DARD\trunk\server\DARDMeatInspection\DARDMeatInspection\services\QABMeatInspectionService.asmx.cs:line 116
   at DARDMeatInspection.services.QABMeatInspectionService.GetAllClassifiers() in D:\DARD\trunk\server\DARDMeatInspection\DARDMeatInspection\services\QABMeatInspectionService.asmx.cs:line 27

Also, is it possible to change content of INI file after deployment?
If I am wrong please correct me. Any help will be highly appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

征棹 2024-11-08 03:17:57

为什么不将配置存储在 app.config/web.config 文件中?

然后使用获取你的值

string test1 = ConfigurationSettings.AppSettings["Test1"];

Why don't you store your configuration in your app.config/web.config file?

Then grab your values using

string test1 = ConfigurationSettings.AppSettings["Test1"];
ペ泪落弦音 2024-11-08 03:17:57

App_Data 可能是一个可行的候选者,特别是因为

应用程序文件夹的内容(App_Themes 文件夹除外)不会响应 Web 请求,但可以从应用程序代码访问。

The App_Data may be a viable candidate, especially because

The content of application folders, except for the App_Themes folder, is not served in response to Web requests, but it can be accessed from application code.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文