コード例 #1
0
ファイル: frmBatch.cs プロジェクト: androidhacker/DotNetProjs
		private void PasswordRequired(object sender, CompressionPasswordRequiredEventArgs e)
		{
			this.Invoke((MethodInvoker)delegate()
			{
				frmPassword dlg = new frmPassword();
				if (dlg.ShowDialog(this) == DialogResult.OK)
				{
					e.Password = dlg.txtPassword.Text;
					e.ContinueOperation = true;
				}
				else
					e.ContinueOperation = false;
			});
		}
コード例 #2
0
		public override int Read(byte[] buffer, int offset, int count)
		{
			if (position == 0 && zipEntry.IsCrypted && ((ZipInputStream)zipStream).Password == null && PasswordRequired != null)
			{
				CompressionPasswordRequiredEventArgs e = new CompressionPasswordRequiredEventArgs();
				PasswordRequired(this, e);
				if (e.ContinueOperation && e.Password.Length > 0)
					((ZipInputStream)zipStream).Password = e.Password;
			}
			// TODO: always save to a local temp circular buffer for optimization of the backwards seek.
			int total = zipStream.Read(buffer, offset, count);
			position += total;
			if (ExtractionProgress != null)
			{
				CompressionExtractionProgressEventArgs e = new CompressionExtractionProgressEventArgs();
				e.BytesExtracted = position;
				e.FileName = zipEntry.Name;
				e.FileSize = zipEntry.Size;
				e.PercentComplete = 100.0 * position / zipEntry.Size;
				ExtractionProgress(this, e);
			}
			return total;
		}
コード例 #3
0
ファイル: Unrar.cs プロジェクト: androidhacker/DotNetProjs
		protected virtual int OnPasswordRequired(IntPtr p1, int p2)
		{
			int result=-1;
			if(this.PasswordRequired!=null)
			{
				CompressionPasswordRequiredEventArgs e = new CompressionPasswordRequiredEventArgs();
				this.PasswordRequired(this, e);
				if(e.ContinueOperation && e.Password.Length>0)
				{
					for(int i=0; (i<e.Password.Length) && (i<p2); i++)
						Marshal.WriteByte(p1, i, (byte)e.Password[i]);
					Marshal.WriteByte(p1, e.Password.Length, (byte)0);
					result=1;
				}
			}
			else
			{
				throw new IOException("Password is required for extraction.");
			}
			return result;
		}
コード例 #4
0
ファイル: CUESheet.cs プロジェクト: androidhacker/DotNetProjs
 private void unzip_PasswordRequired(object sender, CompressionPasswordRequiredEventArgs e)
 {
     if (_archivePassword != null)
     {
         e.ContinueOperation = true;
         e.Password = _archivePassword;
         return;
     }
     if (this.PasswordRequired != null)
     {
         this.PasswordRequired(this, e);
         if (e.ContinueOperation && e.Password != "")
         {
             _archivePassword = e.Password;
             return;
         }
     }
     throw new IOException("Password is required for extraction.");
 }