当前位置: 首页>>代码示例>>C#>>正文


C# IO.MemoryStream类代码示例

本文整理汇总了C#中System.IO.MemoryStream的典型用法代码示例。如果您正苦于以下问题:C# System.IO.MemoryStream类的具体用法?C# System.IO.MemoryStream怎么用?C# System.IO.MemoryStream使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


System.IO.MemoryStream类属于命名空间,在下文中一共展示了System.IO.MemoryStream类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Splash

        public override void Splash()
        {
            byte[] imageBytes = null;

            using (var imageStream = new System.IO.MemoryStream())
            {
                imageStream.Write(imageBytes, 0, imageBytes.Length);

                using (var image = Image.FromStream(imageStream))
                using (var displayForm = new Form
                {
                    Width = 500,
                    Height = 340,
                    TopMost = true,
                    BackColor = Color.Black,
                    StartPosition = FormStartPosition.CenterParent,
                    FormBorderStyle = FormBorderStyle.FixedToolWindow,
                    BackgroundImage = image,
                    BackgroundImageLayout = ImageLayout.None,
                    Text = @"ReplaceMe1"
                })
                {
                    displayForm.ShowDialog();
                }
            }
        }
开发者ID:Virility,项目名称:SplashCreator,代码行数:26,代码来源:ImageSplashTechnique.cs

示例2: busquedaBtn_Click

        private void busquedaBtn_Click(object sender, RoutedEventArgs e)
        {
            Client cliente = ControllerCliente.Instance.buscarCliente(busquedaBox.Text);
            if (cliente == null)
            {
                MessageBox.Show("No existe con ese carnet");
            }
            else
            {
                ciBox.Text = cliente.ci.ToString();
                nombreBox.Text = cliente.nombre;
                PaternoBox.Text = cliente.apellidoPaterno;
                MaternoBox.Text = cliente.apellidoMaterno;
                DomicilioBox.Text = cliente.domicilio;
                ZonaBox.Text = cliente.zona;
                emailBox.Text = cliente.email;
                telefonoCasaBox.Text = cliente.telefonoCasa;
                telefonoOficinaBox.Text = cliente.telefonoOficina;
                feCNacimientoBox.Text = cliente.fechaNacimiento.ToString();
                sexoBox.Text = cliente.sexo;
                BiometricoBox.Text = cliente.codBiometrico;

                System.IO.MemoryStream stream = new System.IO.MemoryStream(cliente.foto);
                BitmapImage foto = new BitmapImage();
                foto.BeginInit();
                foto.StreamSource = stream;
                foto.CacheOption = BitmapCacheOption.OnLoad;
                foto.EndInit();
                image.Source = foto;
            }
        }
开发者ID:irvin373,项目名称:gym,代码行数:31,代码来源:EliminarCliente.xaml.cs

示例3: SplitOrphanPartitionRequest

		/// <summary> 
		/// Constructs an extended operation object for creating an orphan partition.
		/// 
		/// 
		/// </summary>
		/// <param name="serverDN">   The distinguished name of the server on which
		/// the new orphan partition will reside.
		/// 
		/// </param>
		/// <param name="contextName">The distinguished name of the
		/// new orphan partition.
		/// 
		/// </param>
		/// <exception> LdapException A general exception which includes an error message
		/// and an Ldap error code.
		/// </exception>
		public SplitOrphanPartitionRequest(System.String serverDN, System.String contextName):base(ReplicationConstants.CREATE_ORPHAN_NAMING_CONTEXT_REQ, null)
		{
			
			try
			{
				
				if (((System.Object) serverDN == null) || ((System.Object) contextName == null))
					throw new System.ArgumentException(ExceptionMessages.PARAM_ERROR);
				
				System.IO.MemoryStream encodedData = new System.IO.MemoryStream();
				LBEREncoder encoder = new LBEREncoder();
				
				Asn1OctetString asn1_serverDN = new Asn1OctetString(serverDN);
				Asn1OctetString asn1_contextName = new Asn1OctetString(contextName);
				
				asn1_serverDN.encode(encoder, encodedData);
				asn1_contextName.encode(encoder, encodedData);
				
				setValue(SupportClass.ToSByteArray(encodedData.ToArray()));
			}
			catch (System.IO.IOException ioe)
			{
				throw new LdapException(ExceptionMessages.ENCODING_ERROR, LdapException.ENCODING_ERROR, (System.String) null);
			}
		}
开发者ID:REALTOBIZ,项目名称:mono,代码行数:41,代码来源:SplitOrphanPartitionRequest.cs

示例4: SerializeVoxelAreaData

		public static byte[] SerializeVoxelAreaData (VoxelArea v) {
#if !ASTAR_RECAST_CLASS_BASED_LINKED_LIST
			System.IO.MemoryStream stream = new System.IO.MemoryStream();
			System.IO.BinaryWriter writer = new System.IO.BinaryWriter(stream);
			
			writer.Write (v.width);
			writer.Write (v.depth);
			writer.Write (v.linkedSpans.Length);
			
			for (int i=0;i<v.linkedSpans.Length;i++) {
				writer.Write(v.linkedSpans[i].area);
				writer.Write(v.linkedSpans[i].bottom);
				writer.Write(v.linkedSpans[i].next);
				writer.Write(v.linkedSpans[i].top);
			}
			
			//writer.Close();
			writer.Flush();
			Ionic.Zip.ZipFile zip = new Ionic.Zip.ZipFile();
			stream.Position = 0;
			zip.AddEntry ("data",stream);
			System.IO.MemoryStream stream2 = new System.IO.MemoryStream();
			zip.Save(stream2);
			byte[] bytes = stream2.ToArray();
			stream.Close();
			stream2.Close();
			return bytes;
#else
			throw new System.NotImplementedException ("This method only works with !ASTAR_RECAST_CLASS_BASED_LINKED_LIST");
#endif
		}
开发者ID:SpacesAdventure,项目名称:Kio-2,代码行数:31,代码来源:VoxelClasses.cs

示例5: ProcessRequest

 public void ProcessRequest(HttpContext context)
 {
     string TrueName = Utils.GetQueryStringValue("TrueName");
     string CardNo = Utils.GetQueryStringValue("CardNo");
     System.Drawing.Image img = System.Drawing.Image.FromFile(HttpContext.Current.Server.MapPath(VipCardTemplate));
     Graphics g = Graphics.FromImage(img);
     g.DrawImage(img, 0, 0, img.Width, img.Height);
     //设置高质量插值法
     g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.High;
     //设置高质量,低速度呈现平滑程度
     g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
     Font f = new Font("宋体", 17.5f, FontStyle.Bold);
     Brush br = new SolidBrush(Color.FromArgb(100, 80, 80, 80));
     g.DrawString(TrueName, f, br, 52, 200);
     Font f1 = new Font("Arial", 12, FontStyle.Regular);
     Brush br1 = new SolidBrush(Color.FromArgb(100, 102, 102, 102));
     g.DrawString("No:" + CardNo, f1, br1, 25, 225);
     g.Dispose();
     System.IO.MemoryStream ms = new System.IO.MemoryStream();
     img.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
     byte[] imgbyte = ms.ToArray();
     if (imgbyte != null)
     {
         HttpContext.Current.Response.ClearContent();
         HttpContext.Current.Response.ContentType = "image/Jpeg";
         HttpContext.Current.Response.AddHeader("Content-Length", imgbyte.Length.ToString());
         HttpContext.Current.Response.BinaryWrite(imgbyte);
         HttpContext.Current.Response.Flush();
         HttpContext.Current.Response.End();
     }
 }
开发者ID:jslpower,项目名称:jingqu,代码行数:31,代码来源:GetVipCard.ashx.cs

示例6: EncryptAesCbc

        /// <summary>
        /// Encrypt a message using AES in CBC (cipher-block chaining) mode.
        /// </summary>
        /// <param name="plaintext">The message (plaintext) to encrypt</param>
        /// <param name="key">An AES key</param>
        /// <param name="iv">The IV to use or null to use a 0 IV</param>
        /// <param name="addHmac">When set, a SHA256-based HMAC (HMAC256) of 32 bytes using the same key is added to the plaintext
        /// before it is encrypted.</param>
        /// <returns>The ciphertext derived by encrypting the orignal message using AES in CBC mode</returns>
        public static byte[] EncryptAesCbc(byte[] plaintext, byte[] key, byte[] iv = null, bool addHmac = false)
        {
            using (Aes aes =Aes.Create())
//            using (AesCryptoServiceProvider aes = new AesCryptoServiceProvider())
            {
                aes.Key = key;
                if (iv == null)
                    iv = NullIv;
                aes.Mode = CipherMode.CBC;
                aes.IV = iv;

                // Encrypt the message with the key using CBC and InitializationVector=0
                byte[] cipherText;
                using (System.IO.MemoryStream ciphertext = new System.IO.MemoryStream())
                {
                    using (CryptoStream cs = new CryptoStream(ciphertext, aes.CreateEncryptor(), CryptoStreamMode.Write))
                    {
                        cs.Write(plaintext, 0, plaintext.Length);
                        if (addHmac)
                        {
                            byte[] hmac = new HMACSHA256(key).ComputeHash(plaintext);
                            cs.Write(hmac, 0, hmac.Length);
                        }
                        cs.Flush();
                    }
                    cipherText = ciphertext.ToArray();
                }

                return cipherText;
            }
        }
开发者ID:Microsoft,项目名称:StopGuessing,代码行数:40,代码来源:Encryption.cs

示例7: OtherWaysToGetReport

        private static void OtherWaysToGetReport()
        {
            string report = @"d:\bla.rdl";

            // string lalal = System.IO.File.ReadAllText(report);
            // byte[] foo = System.Text.Encoding.UTF8.GetBytes(lalal);
            // byte[] foo = System.IO.File.ReadAllBytes(report);

            using (System.IO.MemoryStream ms = new System.IO.MemoryStream())
            {

                using (System.IO.FileStream file = new System.IO.FileStream(report, System.IO.FileMode.Open, System.IO.FileAccess.Read))
                {
                    byte[] bytes = new byte[file.Length];
                    file.Read(bytes, 0, (int)file.Length);
                    ms.Write(bytes, 0, (int)file.Length);
                    ms.Flush();
                    ms.Position = 0;
                }

                using (System.IO.Stream stream = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("resource"))
                {
                    using (System.IO.TextReader reader = new System.IO.StreamReader(ms))
                    {
                        // rv.LocalReport.LoadReportDefinition(reader);
                    }
                }

                using (System.IO.TextReader reader = System.IO.File.OpenText(report))
                {
                    // rv.LocalReport.LoadReportDefinition(reader);
                }

            }
        }
开发者ID:ststeiger,项目名称:ReportViewerWrapper,代码行数:35,代码来源:SQL.cs

示例8: Zip

 /********************************************************
 * CLASS METHODS
 *********************************************************/
 /// <summary>
 /// 
 /// </summary>
 /// <param name="zipPath"></param>
 /// <param name="filenamesAndData"></param>
 /// <returns></returns>
 public static bool Zip(string zipPath, System.Collections.Generic.Dictionary<string, string> filenamesAndData)
 {
     var success = true;
     var buffer = new byte[4096];
     try
     {
         using (var stream = new ZipOutputStream(System.IO.File.Create(zipPath)))
         {
             foreach (var filename in filenamesAndData.Keys)
             {
                 var file = filenamesAndData[filename].GetBytes();
                 var entry = stream.PutNextEntry(filename);
                 using (var ms = new System.IO.MemoryStream(file))
                 {
                     int sourceBytes;
                     do
                     {
                         sourceBytes = ms.Read(buffer, 0, buffer.Length);
                         stream.Write(buffer, 0, sourceBytes);
                     }
                     while (sourceBytes > 0);
                 }
             }
             stream.Flush();
             stream.Close();
         }
     }
     catch (System.Exception err)
     {
         System.Console.WriteLine("Compression.ZipData(): " + err.Message);
         success = false;
     }
     return success;
 }
开发者ID:rchien,项目名称:ToolBox,代码行数:43,代码来源:Compression.cs

示例9: ReceiveAllUpdatesRequest

		/// <summary> 
		/// Constructs an extended operation object for receiving all updates from
		/// another directory server for a specific replica.
		/// 
		/// </summary>
		/// <param name="partitionRoot">  The distinguished name of the replica
		/// that will be updated.
		/// 
		/// </param>
		/// <param name="toServerDN">     The distinguished name of the server holding the
		/// replica to be updated.
		/// 
		/// </param>
		/// <param name="fromServerDN">   The distinguished name of the server from which
		/// updates are sent.
		/// 
		/// </param>
		/// <exception> LdapException A general exception which includes an error message
		/// and an Ldap error code.
		/// </exception>
		public ReceiveAllUpdatesRequest(System.String partitionRoot, System.String toServerDN, System.String fromServerDN):base(ReplicationConstants.RECEIVE_ALL_UPDATES_REQ, null)
		{
			
			try
			{
				
				if (((System.Object) partitionRoot == null) || ((System.Object) toServerDN == null) || ((System.Object) fromServerDN == null))
					throw new System.ArgumentException(ExceptionMessages.PARAM_ERROR);
				
				System.IO.MemoryStream encodedData = new System.IO.MemoryStream();
				LBEREncoder encoder = new LBEREncoder();
				
				Asn1OctetString asn1_partitionRoot = new Asn1OctetString(partitionRoot);
				Asn1OctetString asn1_toServerDN = new Asn1OctetString(toServerDN);
				Asn1OctetString asn1_fromServerDN = new Asn1OctetString(fromServerDN);
				
				asn1_partitionRoot.encode(encoder, encodedData);
				asn1_toServerDN.encode(encoder, encodedData);
				asn1_fromServerDN.encode(encoder, encodedData);
				
				setValue(SupportClass.ToSByteArray(encodedData.ToArray()));
			}
			catch (System.IO.IOException ioe)
			{
				throw new LdapException(ExceptionMessages.ENCODING_ERROR, LdapException.ENCODING_ERROR, (System.String) null);
			}
		}
开发者ID:nickchal,项目名称:pash,代码行数:47,代码来源:ReceiveAllUpdatesRequest.cs

示例10: ActualizarUsuario

        public void ActualizarUsuario(String user, String Pwd, String PwdRecover, String PwdAnswer, PictureBox pb)
        {
            try
            {
                sql = new SqlConnection(CadCon.Servidor());
                sql.Open();
                string query = "ActualizarUsuario";
                cmd = new SqlCommand(query, sql);
                cmd.CommandType = System.Data.CommandType.StoredProcedure;

                cmd.Parameters.Add("@usuario", SqlDbType.NVarChar);
                cmd.Parameters.Add("@pass", SqlDbType.NVarChar);
                cmd.Parameters.Add("@PwdRecover", SqlDbType.NVarChar);
                cmd.Parameters.Add("@PwdAnswer", SqlDbType.NVarChar);
                cmd.Parameters.Add("@Foto", SqlDbType.Image);

                cmd.Parameters["@usuario"].Value = user;
                cmd.Parameters["@pass"].Value = Pwd;
                cmd.Parameters["@PwdRecover"].Value = PwdRecover;
                cmd.Parameters["@PwdAnswer"].Value = PwdAnswer;

                System.IO.MemoryStream ms = new System.IO.MemoryStream();
                pb.Image.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
                cmd.Parameters["@Foto"].Value = ms.GetBuffer();
                int f = cmd.ExecuteNonQuery();
                if (f != 0)
                {
                    MessageBox.Show("Actualizado exitosamente", "Usuario Almacenado",
                    MessageBoxButtons.OK, MessageBoxIcon.Information);
                    cmd.Dispose();
                    sql.Close();
                }
            }
            catch (SqlException ex) { MessageBox.Show(ex.Message); }
        }
开发者ID:unscharf,项目名称:Gestion-de-casting,代码行数:35,代码来源:Usuarios.cs

示例11: ToolLine

		public ToolLine()
		{
            System.IO.MemoryStream ms = new System.IO.MemoryStream(Genetibase.NuGenAnnotation.Properties.Resources.Line);
            Cursor = new Cursor(ms);
            ms.Close();
			//Cursor = new Cursor(GetType(), "Line.cur");
		}
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:7,代码来源:ToolLine.cs

示例12: ActionDefinition

 public ActionDefinition(ActionLibrary parent, string name, int id)
 {
     Library = parent;
     GameMakerVersion = 520;
     Name = name;
     ActionID = id;
     System.IO.MemoryStream ms = new System.IO.MemoryStream();
     Properties.Resources.DefaultAction.Save(ms, System.Drawing.Imaging.ImageFormat.Bmp);
     OriginalImage = ms.ToArray();
     ms.Close();
     Image = new System.Drawing.Bitmap(24, 24, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
     System.Drawing.Graphics.FromImage(Image).DrawImage(Properties.Resources.DefaultAction, new System.Drawing.Rectangle(0, 0, 24, 24), new System.Drawing.Rectangle(0, 0, 24, 24), System.Drawing.GraphicsUnit.Pixel);
     (Image as System.Drawing.Bitmap).MakeTransparent(Properties.Resources.DefaultAction.GetPixel(0, Properties.Resources.DefaultAction.Height - 1));
     Hidden = false;
     Advanced = false;
     RegisteredOnly = false;
     Description = string.Empty;
     ListText = string.Empty;
     HintText = string.Empty;
     Kind = ActionKind.Normal;
     InterfaceKind = ActionInferfaceKind.Normal;
     IsQuestion = false;
     ShowApplyTo = true;
     ShowRelative = true;
     ArgumentCount = 0;
     Arguments = new ActionArgument[8];
     for (int i = 0; i < 8; i++) Arguments[i] = new ActionArgument();
     ExecutionType = ActionExecutionType.None;
     FunctionName = string.Empty;
     Code = string.Empty;
 }
开发者ID:joshwyant,项目名称:game-creator,代码行数:31,代码来源:ActionDefinition.cs

示例13: GetColorFromImage

        Color GetColorFromImage(Point p)
        {
            try
            {
                Rect bounds = VisualTreeHelper.GetDescendantBounds(this);
                RenderTargetBitmap rtb = new RenderTargetBitmap((Int32)bounds.Width, (Int32)bounds.Height, 96, 96, PixelFormats.Default);
                rtb.Render(this);

                byte[] arr;
                PngBitmapEncoder png = new PngBitmapEncoder();
                png.Frames.Add(BitmapFrame.Create(rtb));
                using (var stream = new System.IO.MemoryStream())
                {
                    png.Save(stream);
                    arr = stream.ToArray();
                }

                BitmapSource bitmap = BitmapFrame.Create(new System.IO.MemoryStream(arr));

                byte[] pixels = new byte[4];
                CroppedBitmap cb = new CroppedBitmap(bitmap, new Int32Rect((int)p.X, (int)p.Y, 1, 1));
                cb.CopyPixels(pixels, 4, 0);
                return Color.FromArgb(pixels[3], pixels[2], pixels[1], pixels[0]);
            }
            catch (Exception)
            {
                return this.ColorBox.Color;
            }
        }
开发者ID:Gainedge,项目名称:BetterExplorer,代码行数:29,代码来源:GradientStopAdder.cs

示例14: Deserialize

 public static object Deserialize(byte[] data)
 {
     var tempStream = new System.IO.MemoryStream();
     tempStream.Write(data, 0, data.Length);
     tempStream.Seek(0, System.IO.SeekOrigin.Begin);
     return formatter.Deserialize(tempStream);
 }
开发者ID:coder0xff,项目名称:Alterity,代码行数:7,代码来源:SerializationProvider.cs

示例15: decryptRJ256

        public static string decryptRJ256(string target, string key, string iv)
        {
            var rijndael = new System.Security.Cryptography.RijndaelManaged()
            {
                Padding = System.Security.Cryptography.PaddingMode.Zeros,
                Mode = System.Security.Cryptography.CipherMode.CBC,
                KeySize = 256,
                BlockSize = 256
            };

            var keyBytes = Encoding.ASCII.GetBytes(key);
            var ivBytes = Encoding.ASCII.GetBytes(iv);

            var decryptor = rijndael.CreateDecryptor(keyBytes, ivBytes);
            var toDecrypt = Convert.FromBase64String(target);
            var fromEncrypt = new byte[toDecrypt.Length];

            var msDecrypt = new System.IO.MemoryStream(toDecrypt);
            var csDecrypt = new System.Security.Cryptography.CryptoStream(msDecrypt, decryptor, System.Security.Cryptography.CryptoStreamMode.Read);
            csDecrypt.Read(fromEncrypt, 0, fromEncrypt.Length);

            string data = Encoding.ASCII.GetString(fromEncrypt);
            data = data.Replace("\0", "");

            return data;
        }
开发者ID:edualberice,项目名称:AmazonUploader,代码行数:26,代码来源:Cryptography.cs


注:本文中的System.IO.MemoryStream类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。