KeePass.Forms.DataEditorForm.ConvertAttachment C# (CSharp) Méthode

ConvertAttachment() static private méthode

static private ConvertAttachment ( string strDesc, byte pbData ) : byte[]
strDesc string
pbData byte
Résultat byte[]
        internal static byte[] ConvertAttachment(string strDesc, byte[] pbData)
        {
            BinaryDataClass bdc = BinaryDataClassifier.Classify(strDesc, pbData);
            if(bdc == BinaryDataClass.Text)
            {
                string strContext = (KPRes.File + (string.IsNullOrEmpty(strDesc) ?
                    string.Empty : (": " + strDesc)));

                TextEncodingForm dlg = new TextEncodingForm();
                dlg.InitEx(strContext, pbData);
                if(UIUtil.ShowDialogNotValue(dlg, DialogResult.OK)) return null;

                Encoding enc = dlg.SelectedEncoding;
                UIUtil.DestroyForm(dlg);
                if(enc != null)
                {
                    try
                    {
                        string strText = enc.GetString(pbData);
                        return StrUtil.Utf8.GetBytes(strText);
                    }
                    catch(Exception) { Debug.Assert(false); }
                }
            }

            return pbData;
        }