Nexus.Client.Games.Steam.KeyValue.LoadFromFile C# (CSharp) Method

LoadFromFile() static private method

static private LoadFromFile ( string path, bool asBinary ) : KeyValue
path string
asBinary bool
return KeyValue
		static KeyValue LoadFromFile(string path, bool asBinary)
		{
			if (File.Exists(path) == false)
			{
				return null;
			}

			try
			{
				using (var input = File.Open(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
				{
					var kv = new KeyValue(null, null);

					if (asBinary)
					{
						if (kv.ReadAsBinary(input) == false)
						{
							return null;
						}
					}
					else
					{
						if (kv.ReadAsText(input) == false)
						{
							return null;
						}
					}

					return kv;
				}
			}
			catch (Exception)
			{
				return null;
			}
		}