IPATools.PlistEditor.PlistInfo.Read C# (CSharp) Method

Read() public method

public Read ( ) : bool
return bool
        public bool Read()
        {
            bool b = false;
            if (Info.Exists)
            {
                fs = new FileStream(Info.FullName, FileMode.Open, FileAccess.ReadWrite);
                pt = Plist.getPlistType(fs);
                IsBinary = pt == plistType.Binary;
                fs.Position = 0;
                try
                {
                    object obj = Plist.readPlist(fs, pt);
                    Content = Plist.writeXml(obj);
                    b = true;
                }
                catch (Exception ex)
                {
                    Debug.WriteLine(ex);
                    try
                    {
                        if (fs != null && pt == plistType.Xml)
                        {
                            fs.Position = 0;
                            byte[] bytes = new byte[(int)fs.Length];
                            if (fs.Read(bytes, 0, bytes.Length)>0)
                            {
                                Content = Encoding.UTF8.GetString(bytes);
                            }
                        }
                    }
                    catch (Exception exx)
                    {
                        Debug.WriteLine(exx);
                    }
                }

            }
            return b;
        }

Usage Example

Ejemplo n.º 1
0
        public void Open(FarsiLibrary.Win.FATabStrip faTabStripMain, string path="")
        {
            using (OpenFileDialog ofd = new OpenFileDialog())
            {
                if (string.IsNullOrEmpty(path))
                {
                    ofd.Filter = "PList(*.plist)|*.plist|All files|*.*";
                    if (ofd.ShowDialog() == DialogResult.OK)
                    {
                        path = ofd.FileName;
                    }
                }
                if (!string.IsNullOrEmpty(path))
                {
                    try
                    {
                        PlistInfo p = new PlistInfo(path);
                        bool suc = p.Read();
                        CreateTab(faTabStripMain, p.Info.Name, p);

                        if (!suc)
                        {
                            MessageBox.Show("Xml format error");
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                        Debug.WriteLine(ex);
                    }
                }
            }
        }
All Usage Examples Of IPATools.PlistEditor.PlistInfo::Read