Пример #1
0
		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);
					}
				}
			}
		}
Пример #2
0
        public RarOpener(BinaryData inputData)
        {
			m_rar = new Chilkat.Rar();

            m_fileName = Path.GetTempFileName();
            inputData.Save(m_fileName);
            if (!m_rar.Open(m_fileName))
            {
                throw new Exception(m_rar.LastErrorText);
            }
        }