public ZipOpener(BinaryData inputData, string password)
		{
			m_zip = new ZipWrapper();
			m_zip.SetPassword(password);

			if (inputData.Length >= 85000)
			{
				m_fileName = Path.GetTempFileName();
				inputData.Save(m_fileName);
				if (!m_zip.OpenZip(m_fileName))
				{
					throw new System.Exception(m_zip.LastErrorText);
				}
			}
			else
			{
				using (Stream str = inputData.AsStream())
				{
					byte[] data = StreamUtils.SafeButUnpleasantReadAllStreamIntoByteArray(str);

					if (!m_zip.OpenFromMemory(data))
					{
						throw new System.Exception(m_zip.LastErrorText);
					}
				}
			}
		}
Exemple #2
0
		public static bool IsDataHTML(BinaryData fileData)
		{
			byte[] byteArray = new byte[4];
			using (Stream str = fileData.AsStream())
			{
				str.Read(byteArray, 0, 4);
				Encoding encoding = FindEncoding(ref byteArray);

				string dataString = fileData.AsString(10240, encoding).ToLowerInvariant();
				// Trim off byte order marks from the beginning of the string
				dataString = dataString.TrimStart(new char[] { '\xFEFF', '\xFFFE' });

				return IsStringHTML(dataString);
			}
		}