コード例 #1
0
ファイル: LoginView.cs プロジェクト: mengtest/DragonBallNew
    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();
    }
コード例 #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);
        }
コード例 #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);
        }
コード例 #4
0
ファイル: CompressionFile.cs プロジェクト: 892182825/SP
    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);
    }
コード例 #5
0
ファイル: ZipCreator.cs プロジェクト: mengtest/DragonBallNew
        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);
        }
コード例 #6
0
ファイル: ZipTest.cs プロジェクト: mengtest/DragonBallNew
    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);
        }
    }
コード例 #7
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服务器上不存在该文件");
            //}
        }