Beispiel #1
0
        /// <summary>
        /// 读取Plist文件为Json字符串 即将删除慎用
        /// </summary>
        /// <param name="srcPath">文件路径</param>
        /// <param name="savePath">保存路径</param>
        /// <returns>Json字符串</returns>
        public static bool ReadPListToFile(string srcPath, string savePath)
        {
            try
            {
                if (!System.IO.File.Exists(savePath))
                {
                    return(false);
                }

                int mountResult = BPListDllCore.OpenPFile(srcPath);
                if (mountResult != 0)
                {
                    return(false);
                }

                int result = BPListDllCore.GetJsonFile(savePath);
                if (result != 0)
                {
                    return(false);
                }

                return(true);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                return(false);
            }
            finally
            {
                BPListDllCore.Close();
            }
        }
Beispiel #2
0
        /// <summary>
        /// 将Json字节转化为Json字符串 即将删除慎用
        /// </summary>
        /// <param name="jsonBuffer"></param>
        /// <param name="size"></param>
        /// <returns></returns>
        public static string ConvertToJsonString(byte[] jsonBuffer, int size)
        {
            try
            {
                int openCode = BPListDllCore.OpenPBuffer(jsonBuffer, size);

                if (openCode != 0)
                {
                    return(string.Empty);
                }

                IntPtr result     = IntPtr.Zero;
                int    resultCode = BPListDllCore.GetJsonBuffer(ref result);
                if (resultCode != 0)
                {
                    return(string.Empty);
                }

                string jsonString = result.ToUTF8String();
                BPListDllCore.Close();
                return(jsonString);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                return(string.Empty);
            }
        }
Beispiel #3
0
        /// <summary>
        /// 读取Plist文件为Json字符串 即将删除慎用
        /// </summary>
        /// <param name="plistFilePath">文件路径</param>
        /// <returns>Json字符串</returns>
        public static string ReadToJsonString(string plistFilePath)
        {
            try
            {
                int mountResult = BPListDllCore.OpenPFile(plistFilePath);
                if (mountResult != 0)
                {
                    return(string.Empty);
                }

                IntPtr result     = IntPtr.Zero;
                int    resultCode = BPListDllCore.GetJsonBuffer(ref result);
                if (resultCode != 0)
                {
                    return(string.Empty);
                }

                string jsonString = result.ToUTF8String();
                BPListDllCore.Close();
                return(jsonString);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }

            return(string.Empty);
        }