示例#1
0
        private void CacheAddress(IpAddressInfo address)
        {
            if (_cachedIpAddress != null && _cachedIpAddress.Equals(address))
            {
                // no need to update the file if the address has not changed
                return;
            }

            var path = CacheFilePath;

            try
            {
                _fileSystem.CreateDirectory(Path.GetDirectoryName(path));
            }
            catch (Exception ex)
            {
            }

            try
            {
                _fileSystem.WriteAllText(path, _encryption.EncryptString(address.ToString()), Encoding.UTF8);
                _cachedIpAddress = address;
            }
            catch (Exception ex)
            {
                _logger.ErrorException("Error saving data", ex);
            }
        }
示例#2
0
        private void CacheAddress(IpAddressInfo address)
        {
            var path = CacheFilePath;

            try
            {
                _fileSystem.CreateDirectory(Path.GetDirectoryName(path));
                _fileSystem.WriteAllText(path, address.ToString(), Encoding.UTF8);
            }
            catch (Exception ex)
            {
                _logger.ErrorException("Error saving data", ex);
            }
        }