我编写了一个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文件的内容? 如果我错了,请纠正我。任何帮助将受到高度赞赏。
答案 0 :(得分:3)
为什么不将配置存储在app.config / web.config文件中?
然后使用
获取您的值string test1 = ConfigurationSettings.AppSettings["Test1"];
答案 1 :(得分:2)
App_Data可能是一个可行的候选人,尤其是因为
应用程序文件夹的内容(App_Themes文件夹除外)不会响应Web请求而提供,但可以从应用程序代码访问它。