Exemple #1
0
    IEnumerator RunUnZipFile()
    {
        yield return(new WaitForEndOfFrame());

        configLoading.SetDescribe(Core.Data.stringManager.getString(9028));
        configLoading.ShowLoading(0);
        string ConfigPath = System.IO.Path.Combine(DeviceInfo.PersistRootPath, "Config.zip");

        MessageDigest_Algorithm.getFileMd5Hash(ConfigPath);

        string[] FileProperties = new string[2];
        //待解压的文件
        FileProperties[0] = ConfigPath;
        //解压后放置的目标目录
        FileProperties[1] = DeviceInfo.PersistRootPath;
        UnZipClass UnZc = new UnZipClass();

        UnZc.UnZip(FileProperties);

        yield return(new WaitForEndOfFrame());

        configLoading.ShowLoading(1);

        yield return(new WaitForEndOfFrame());

        configLoading.gameObject.SetActive(false);
        //解压完成以后读表
        readLocalConfig();
    }
Exemple #2
0
        private void butProjectFolder_Click(object sender, EventArgs e)
        {
            // FolderBrowserDialog folderBrowser = new FolderBrowserDialog();
            //folderBrowserDialog.SelectedPath = @"D:\"; // 设置打开目录选择对话框时默认的目录
            //folderBrowserDialog.ShowNewFolderButton = true; // false; //是否显示新建文件夹按钮
            //folderBrowserDialog.Description = "设置项目的目录"; //描述弹出框功能
            //folderBrowserDialog.RootFolder = Environment.SpecialFolder.MyComputer; //.MyDocuments.MyDocuments; // 打开到我的文档

            folderBrowserDialog.ShowDialog();                                  // 打开目录选择对话框
            SystemConstants.StrProjectPath = folderBrowserDialog.SelectedPath; // 返回用户选择的目录地址

            #region  制减速器模版到项目目录

            string[] fileProperties = new string[2];
            fileProperties[0] = @"D:\zip\减速器.zip";                     //待解压的文件
            fileProperties[1] = SystemConstants.StrProjectPath + "\\"; // @"D:\unzipped\"; //解压后放置的目标目录
            UnZipClass UnZc = new UnZipClass();
            UnZc.UnZip(fileProperties);

            #endregion

            #region 把减速器基本参数写入 “减速器.xml” 文件

            SystemConstants.XmlProject = XElement.Load(SystemConstants.StrProjectPath + @"\减速器.xml");
            SystemConstants.XmlProject.Element("总体要求").Element("级数").Value   = cmbGradeOfReducer.Text;
            SystemConstants.XmlProject.Element("总体要求").Element("结构形式").Value = cmbTypeOfReducer.Text;
            SystemConstants.XmlProject.Element("总体要求").Element("总功率").Value  = txtP.Text;
            SystemConstants.XmlProject.Element("总体要求").Element("转速").Value   = txtN.Text;
            SystemConstants.XmlProject.Element("总体要求").Element("总速比").Value  = txtTotalRate.Text;
            SystemConstants.XmlProject.Save(SystemConstants.StrProjectPath + @"\减速器.xml");

            #endregion

            //MessageBox.Show(strProjectPath);
        }
Exemple #3
0
        private void button3_Click(object sender, EventArgs e)
        {
            string[] FileProperties = new string[2];
            FileProperties[0] = @"D:\zip\2.zip"; //待解压的文件
            FileProperties[1] = @"D:\unzipped\"; //解压后放置的目标目录
            UnZipClass UnZc = new UnZipClass();

            UnZc.UnZip(FileProperties);
        }
 private void UpdateAndwhoData()
 {
     try
     {
         if (File.Exists(Application.StartupPath + @"\Andwho.zip"))
         {
             UnZipClass unZip   = new UnZipClass();
             string     errMsg  = string.Empty;
             bool       success = unZip.UnZipFile(Application.StartupPath + @"\Andwho.zip", Application.StartupPath + @"\", out errMsg);
             if (success && SaveUserConfig())
             {
                 File.Delete(Application.StartupPath + @"\Data\Andwho.db");
                 File.Delete(Application.StartupPath + @"\Andwho.zip");
                 File.Move(Application.StartupPath + @"\Andwho.db", Application.StartupPath + @"\Data\Andwho.db");
             }
         }
         #region Image
         if (File.Exists(Application.StartupPath + @"\hong.png"))
         {
             File.Delete(Application.StartupPath + @"\hong.png");
         }
         if (File.Exists(Application.StartupPath + @"\huang.png"))
         {
             File.Delete(Application.StartupPath + @"\huang.png");
         }
         if (File.Exists(Application.StartupPath + @"\lv.png"))
         {
             File.Delete(Application.StartupPath + @"\lv.png");
         }
         //if (!Directory.Exists(Application.StartupPath + @"\Image"))
         //{
         //    Directory.CreateDirectory(Application.StartupPath + @"\Image");
         //}
         //if (File.Exists(Application.StartupPath + @"\green.png"))
         //{
         //    if (!File.Exists(Application.StartupPath + @"\Image\green.png"))
         //        File.Move(Application.StartupPath + @"\green.png", Application.StartupPath + @"\Image\green.png");
         //}
         //if (File.Exists(Application.StartupPath + @"\yellow.png"))
         //{
         //    if (!File.Exists(Application.StartupPath + @"\Image\yellow.png"))
         //        File.Move(Application.StartupPath + @"\yellow.png", Application.StartupPath + @"\Image\yellow.png");
         //}
         //if (File.Exists(Application.StartupPath + @"\red.png"))
         //{
         //    if (!File.Exists(Application.StartupPath + @"\Image\red.png"))
         //        File.Move(Application.StartupPath + @"\red.png", Application.StartupPath + @"\Image\red.png");
         //}
         #endregion
     }
     catch (Exception ex)
     {
         log.WriteLog(ex.ToString());
     }
 }
Exemple #5
0
    public static void UpZip(string zipFile)
    {
        string [] FileProperties = new string[2];

        FileProperties[0] = zipFile;                                             //待解压的文件

        FileProperties[1] = zipFile.Substring(0, zipFile.LastIndexOf("\\") + 1); //解压后放置的目标目录

        UnZipClass UnZc = new UnZipClass();

        UnZc.UnZip(FileProperties);
    }
Exemple #6
0
        static void UnZipConfig()
        {
            string [] FileProperties = new string[2];
            //待解压的文件
            FileProperties[0] = System.IO.Path.Combine(Application.streamingAssetsPath, "Config.zip");
            //string ConfigPath = System.IO.Path.Combine(DeviceInfo.PersistRootPath,"Config.zip");
            //解压后放置的目标目录
            FileProperties[1] = Application.streamingAssetsPath;
            UnZipClass UnZc = new UnZipClass();

            UnZc.UnZip(FileProperties);
        }
 private void UpdateAndwhoData()
 {
     try
     {
         if (File.Exists(System.Windows.Forms.Application.StartupPath + @"\Update\DeskHelper.xml"))
         {
             File.Delete(System.Windows.Forms.Application.StartupPath + @"\Update\DeskHelper.xml");
         }
         if (File.Exists(System.Windows.Forms.Application.StartupPath + @"\Andwho.zip"))
         {
             UnZipClass unZip   = new UnZipClass();
             string     errMsg  = string.Empty;
             bool       success = unZip.UnZipFile(System.Windows.Forms.Application.StartupPath + @"\Andwho.zip", System.Windows.Forms.Application.StartupPath + @"\", out errMsg);
             if (success && SaveUserConfig())
             {
                 File.Delete(System.Windows.Forms.Application.StartupPath + @"\Data\Andwho.db");
                 File.Delete(System.Windows.Forms.Application.StartupPath + @"\Andwho.zip");
                 File.Move(System.Windows.Forms.Application.StartupPath + @"\Andwho.db", System.Windows.Forms.Application.StartupPath + @"\Data\Andwho.db");
             }
         }
         #region Image
         if (!Directory.Exists(System.Windows.Forms.Application.StartupPath + @"\Image"))
         {
             Directory.CreateDirectory(System.Windows.Forms.Application.StartupPath + @"\Image");
         }
         if (File.Exists(System.Windows.Forms.Application.StartupPath + @"\lv.png"))
         {
             if (!File.Exists(System.Windows.Forms.Application.StartupPath + @"\Image\lv.png"))
             {
                 File.Move(System.Windows.Forms.Application.StartupPath + @"\lv.png", System.Windows.Forms.Application.StartupPath + @"\Image\lv.png");
             }
         }
         if (File.Exists(System.Windows.Forms.Application.StartupPath + @"\huang.png"))
         {
             if (!File.Exists(System.Windows.Forms.Application.StartupPath + @"\Image\huang.png"))
             {
                 File.Move(System.Windows.Forms.Application.StartupPath + @"\huang.png", System.Windows.Forms.Application.StartupPath + @"\Image\huang.png");
             }
         }
         if (File.Exists(System.Windows.Forms.Application.StartupPath + @"\hong.png"))
         {
             if (!File.Exists(System.Windows.Forms.Application.StartupPath + @"\Image\hong.png"))
             {
                 File.Move(System.Windows.Forms.Application.StartupPath + @"\hong.png", System.Windows.Forms.Application.StartupPath + @"\Image\hong.png");
             }
         }
         #endregion
     }
     catch
     {
     }
 }
Exemple #8
0
            public static DataSet arrByteToDataSet(byte[] zipBuffer)
            {
                if (zipBuffer == null || zipBuffer.Length < 1)
                {
                    return(null);
                }
                byte[]           buffer  = UnZipClass.Decompress(zipBuffer);
                BinaryFormatter  ser     = new BinaryFormatter();
                DataSetSurrogate dss     = ser.Deserialize(new MemoryStream(buffer)) as DataSetSurrogate;
                DataSet          dataSet = dss.ConvertToDataSet();

                return(dataSet);
            }
Exemple #9
0
        private void button4_Click(object sender, EventArgs e)
        {
            WebServices.SOAPTEST.SOAPTEST ds = new WebServices.SOAPTEST.SOAPTEST();

            DateTime dtBegin = DateTime.Now;

            byte[]           zipBuffer = ds.GetDataSetSurrogateZipBytes();
            byte[]           buffer    = UnZipClass.Decompress(zipBuffer);
            BinaryFormatter  ser       = new BinaryFormatter();
            DataSetSurrogate dss       = ser.Deserialize(new MemoryStream(buffer)) as DataSetSurrogate;
            DataSet          dataSet   = dss.ConvertToDataSet();

            this.label4.Text = string.Format("耗时:{0}", DateTime.Now - dtBegin) + "  " + zipBuffer.Length;
            binddata(dataSet);
        }
Exemple #10
0
    void OnGUI()
    {
        if (GUI.Button(new Rect(400, 130, 100, 50), "ZipClass"))
        {
            string [] FileProperties = new string[2];
            //待压缩文件目录
            FileProperties[0] = @"/Users/jiangcheng/Desktop/ziptest";
            //压缩后的目标文件
            FileProperties[1] = @"/Users/jiangcheng/Desktop/a.zip";
            ZipClass Zc = new ZipClass();
            Zc.ZipFileMain(FileProperties);

            //Debug.Log(DeviceInfo.StreamingPath);
//			ZipClass Zc=new ZipClass();
//			Zc.ZipFile(@"/Users/jiangcheng/Desktop/ziptest",@"/Users/jiangcheng/Desktop/a.zip",6,2048);
        }

        if (GUI.Button(new Rect(400, 200, 100, 50), "UnZipClass"))
        {
            string ConfigPath = System.IO.Path.Combine(DeviceInfo.StreamingPath, "Config.zip");
            //string ConfigMD5 = MessageDigest_Algorithm.getFileMd5Hash(ConfigPath);
            Debug.Log(Core.Data.guideManger.getBasePath());

            string [] FileProperties = new string[2];
            //待解压的文件
            FileProperties[0] = ConfigPath;
            //解压后放置的目标目录
            FileProperties[1] = Core.Data.guideManger.getBasePath();
            UnZipClass UnZc = new UnZipClass();
            UnZc.UnZip(FileProperties);
        }

        if (GUI.Button(new Rect(400, 270, 100, 50), "GetMD5"))
        {
            string ConfigPath = System.IO.Path.Combine(DeviceInfo.StreamingPath, "Config.zip");
            string ConfigMD5  = MessageDigest_Algorithm.getFileMd5Hash(ConfigPath);
            Debug.Log(ConfigMD5);
        }

        if (GUI.Button(new Rect(400, 340, 100, 50), "DownLoad"))
        {
            string ConfigPath = System.IO.Path.Combine(DeviceInfo.StreamingPath, "Config.zip");
            string ConfigMD5  = MessageDigest_Algorithm.getFileMd5Hash(ConfigPath);
            test_DownloadResource(ConfigMD5);
        }
    }
Exemple #11
0
        //新增通过FTP地址方式下载方法
        public bool DownFTPFile(int groupid, string strFileName, string strLocalFile, string remoteSeverPath)
        {
            string filename = "";
            string pathname = "";

            try
            {
                if (_ftpFac == null)
                {
                    _ftpFac = new FTPClient(exFTPConnection1.ServerAddress, exFTPConnection1.UserName, exFTPConnection1.Password, exFTPConnection1.ServerPort);
                }
                strFileName = strFileName.Replace("\\", "/").TrimStart('/');
                if (groupid < 0)
                {
                    //string rppath = getReportPath((-groupid).ToString());
                    if (strFileName.IndexOf("/") > -1)
                    {
                        filename = strFileName.Substring(strFileName.LastIndexOf("/"), strFileName.Length - strFileName.LastIndexOf("/"));
                        pathname = remoteSeverPath + "/" + strFileName.Substring(0, strFileName.LastIndexOf("/"));
                    }
                }
                else
                {
                    if (strFileName.IndexOf("/") > -1)
                    {
                        filename = strFileName.Substring(strFileName.LastIndexOf("/"), strFileName.Length - strFileName.LastIndexOf("/"));
                        pathname = remoteSeverPath + "/" + strFileName.Substring(0, strFileName.LastIndexOf("/"));
                    }
                    else
                    {
                        throw new Exception(msgContent);
                        return(false);
                    }
                }
                //if (_ftpFac.fileCheckExist(pathname, filename.TrimStart('/')))
                //{
                bool result = _ftpFac.fileDownload(strLocalFile, filename, pathname, filename);
                if (!result)
                {
                    string errstring  = string.Format("无法下载以下地址的文件:ftp://{0}/{1}{2}", exFTPConnection1.ServerAddress, pathname, filename);
                    string errstring2 = "";
                    #if DEBUG
                    errstring2 = string.Format("\n 端口为:{2} 登陆用户名:{0} 密码:{1}", exFTPConnection1.UserName, exFTPConnection1.Password, exFTPConnection1.ServerPort);
                    #endif
                    LogFile.WriteToFile("", errstring + errstring2, 2);
                }
                string filelastname = filename.Substring(filename.LastIndexOf("."), filename.Length - filename.LastIndexOf(".")).ToLower();
                if (filelastname == ".zip" || filelastname == ".rar")
                {
                    UnZipClass.UnZip(strLocalFile + filename, strLocalFile, "");
                    if (File.Exists(strLocalFile + filename))
                    {
                        File.Delete(strLocalFile + filename);
                    }
                }
                return(result);
            }
            catch (Exception ex)
            {
                string errstring  = string.Format("无法下载以下地址的文件:ftp://{0}/{1}{2}", exFTPConnection1.ServerAddress, pathname, filename);
                string errstring2 = "";
                #if DEBUG
                errstring2 = string.Format("\n 端口为:{2} 登陆用户名:{0} 密码:{1}", exFTPConnection1.UserName, exFTPConnection1.Password, exFTPConnection1.ServerPort);
                #endif
                LogFile.WriteToFile(ex.Message, errstring + errstring2, 2);
                if (ex.Message == msgContent)
                {
                    throw new Exception(msgContent);
                }
                else
                {
                    throw new Exception("连接FTP失败或者FTP服务器上不存在该文件!");
                }
            }
            //}
            //else
            //{
            //    throw new Exception("FTP服务器上不存在该文件");
            //}
        }