我的网站使用数据库来定位客户所在国家/地区。
这是我的错误代码:
System.IO.IOException
Inner Exception:
The process cannot access the file 'C:\*****\******\wwwroot\GEO2db\GeoLite2-Country.mmdb' because it is being used by another process.
以下是我从数据库中获取国家的代码(在我的母版页中调用):
Public Function GetGeoIPCountry() As String
If HttpContext.Current.Request.IsLocal Then
Return ""
End If
Dim ip As String = HttpContext.Current.Request.ServerVariables("REMOTE_ADDR")
Dim FileWithPath As String = HttpContext.Current.Server.MapPath("~") & "GEO2db\GeoLite2-Country.mmdb"
Dim reader = New DatabaseReader(FileWithPath)
Dim Om = reader.Omni(ip)
Dim country As String = Om.Country.Name
reader.Dispose()
Return country
End Function