Exemplo n.º 1
0
        /// <summary>
        /// Save data into a file.
        /// </summary>
        /// <param name="fileName">File name.</param>
        public void SaveData(string fileName)
        {
            FileStream fs = new FileStream(fileName, FileMode.Create);

            rootNode.SaveData(fs);
            fs.Close();
        }
        public static void Copy(Asn1Node node)
        {
            DataFormats.GetFormat(Asn1ClipboardData.asn1FormatName);
            MemoryStream memoryStream = new MemoryStream();

            node.SaveData((Stream)memoryStream);
            memoryStream.Position = 0L;
            byte[] numArray = new byte[memoryStream.Length];
            memoryStream.Read(numArray, 0, (int)memoryStream.Length);
            memoryStream.Close();
            DataObject dataObject = new DataObject();

            dataObject.SetData(Asn1ClipboardData.asn1FormatName, (object)numArray);
            dataObject.SetData(DataFormats.Text, (object)Asn1Util.FormatString(Asn1Util.ToHexString(numArray), 32, 2));
            Clipboard.SetDataObject((object)dataObject, true);
        }
        /// <summary>
        /// Copy Asn1Node data into clipboard as Asn1NodeDataFormat and Text format.
        /// </summary>
        /// <param name="node">Asn1Node</param>
        public static void Copy(Asn1Node node)
        {
            DataFormats.Format asn1Format = DataFormats.GetFormat(asn1FormatName);
			MemoryStream ms = new MemoryStream();
			node.SaveData(ms);
			ms.Position = 0;
			byte[] ndata = new byte[ms.Length];
			ms.Read(ndata, 0, (int)ms.Length);
			ms.Close();
            DataObject aDataObj = new DataObject();
            aDataObj.SetData(asn1FormatName, ndata);
            aDataObj.SetData(
                DataFormats.Text, 
                Asn1Util.FormatString(Asn1Util.ToHexString(ndata), 32, 2));
            Clipboard.SetDataObject(aDataObj, true);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Copy Asn1Node data into clipboard as Asn1NodeDataFormat and Text format.
        /// </summary>
        /// <param name="node">Asn1Node</param>
        public static void Copy(Asn1Node node)
        {
            DataFormats.Format asn1Format = DataFormats.GetFormat(asn1FormatName);
            MemoryStream       ms         = new MemoryStream();

            node.SaveData(ms);
            ms.Position = 0;
            byte[] ndata = new byte[ms.Length];
            ms.Read(ndata, 0, (int)ms.Length);
            ms.Close();
            DataObject aDataObj = new DataObject();

            aDataObj.SetData(asn1FormatName, ndata);
            aDataObj.SetData(
                DataFormats.Text,
                Asn1Util.FormatString(Asn1Util.ToHexString(ndata), 32, 2));
            Clipboard.SetDataObject(aDataObj, true);
        }
Exemplo n.º 5
0
 public void SaveNodeAsPemFile(Asn1Node aNode, string fileName, string pemHeader)
 {
     MemoryStream ms = new MemoryStream();
     aNode.SaveData(ms);
     editingFileSize = (int)ms.Length;
     ShowCurrentFileInfo();
     byte[] bytes = new byte[ms.Length];
     ms.Position = 0;
     ms.Read(bytes, 0, bytes.Length);
     ms.Close();
     string pemStr = Asn1Util.BytesToPem(bytes, pemHeader);
     FileStream fs = new FileStream(fileName, System.IO.FileMode.Create);
     bytes = Asn1Util.StringToBytes(pemStr);
     fs.Write(bytes, 0, bytes.Length);
     fs.Close();
 }