wyUpdate.Common.WriteFiles.WriteByteArray C# (CSharp) Method

WriteByteArray() public static method

public static WriteByteArray ( Stream fs, byte flag, byte arr ) : void
fs Stream
flag byte
arr byte
return void
        public static void WriteByteArray(Stream fs, byte flag, byte[] arr)
        {
            byte[] tempLength = BitConverter.GetBytes(arr.Length);

            //write the flag (e.g. 0x01, 0xFF, etc.)
            fs.WriteByte(flag);

            //write the byte data
            fs.Write(tempLength, 0, 4);
            fs.Write(arr, 0, arr.Length);
        }

Usage Example

Ejemplo n.º 1
0
        public void WriteToStream(Stream fs, bool embedBinaryData)
        {
            fs.WriteByte(142);
            WriteFiles.WriteInt(fs, 1, (int)RegOperation);
            WriteFiles.WriteInt(fs, 2, (int)RegBasekey);
            WriteFiles.WriteInt(fs, 3, (int)RegValueKind);
            WriteFiles.WriteDeprecatedString(fs, 4, SubKey);
            if (!string.IsNullOrEmpty(ValueName))
            {
                WriteFiles.WriteDeprecatedString(fs, 5, ValueName);
            }
            bool flag = !embedBinaryData && RegValueKind == RegistryValueKind.Binary && ValueData is string;

            if (flag)
            {
                fs.WriteByte(128);
            }
            if (RegOperation == RegOperations.CreateValue)
            {
                switch (RegValueKind)
                {
                case RegistryValueKind.Binary:
                    if (flag)
                    {
                        WriteFiles.WriteDeprecatedString(fs, 7, (string)ValueData);
                    }
                    else if (embedBinaryData && RegValueKind == RegistryValueKind.Binary && ValueData is string)
                    {
                        WriteOutFile(fs, 7, (string)ValueData);
                    }
                    else
                    {
                        WriteFiles.WriteByteArray(fs, 7, (byte[])ValueData);
                    }
                    break;

                case RegistryValueKind.DWord:
                    WriteFiles.WriteInt(fs, 7, (int)ValueData);
                    break;

                case RegistryValueKind.QWord:
                    WriteFiles.WriteLong(fs, 7, (long)ValueData);
                    break;

                case RegistryValueKind.MultiString:
                    WriteFiles.WriteDeprecatedString(fs, 7, MultiStringToString(ValueData));
                    break;

                case RegistryValueKind.String:
                case RegistryValueKind.ExpandString:
                    WriteFiles.WriteDeprecatedString(fs, 7, (string)ValueData);
                    break;
                }
            }
            if (Is32BitKey)
            {
                fs.WriteByte(129);
            }
            fs.WriteByte(158);
        }
All Usage Examples Of wyUpdate.Common.WriteFiles::WriteByteArray