[英]Where to save INI file in ASP.NET web service application
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, 我编写了一个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
Also, is it possible to change content of INI file after deployment? 另外,部署后是否可以更改INI文件的内容? If I am wrong please correct me. 如果我错了,请纠正我。 Any help will be highly appreciated. 任何帮助将不胜感激。
Why don't you store your configuration in your app.config/web.config file? 为什么不将配置存储在app.config / web.config文件中?
Then grab your values using 然后使用
string test1 = ConfigurationSettings.AppSettings["Test1"];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.