Exemplo n.º 1
0
    public static void MultiUnzip(byte[] zipbytes, string dir)
    {
        BinaryReader binaryReader = new BinaryReader(new MemoryStream(zipbytes));

        while (binaryReader.BaseStream.Position < binaryReader.BaseStream.Length)
        {
            string       str          = binaryReader.ReadString();
            int          count        = binaryReader.ReadInt32();
            byte[]       array        = binaryReader.ReadBytes(count);
            MemoryStream memoryStream = new MemoryStream();
            memoryStream.Write(array, 0, array.Length);
            memoryStream.Position = 0L;
            MemoryStream memoryStream2 = new MemoryStream();
            StreamZip.Unzip(memoryStream, memoryStream2);
            if (!QFileUtils.ExistsDir(dir))
            {
                QFileUtils.CreateDir(dir);
            }
            string fileName = dir + "//" + str;
            if (!QFileUtils.Exists(fileName))
            {
                QFileUtils.CreateFile(fileName);
            }
            QFileUtils.WriteBytes(fileName, memoryStream2.ToArray());
        }
    }
Exemplo n.º 2
0
    public static void UnZipScene()
    {
        string text  = SceneZip.unZipPath + "/Scene.bytes";
        int    count = SceneZip.sceneZipReader.ReadInt32();

        byte[]       array        = SceneZip.sceneZipReader.ReadBytes(count);
        MemoryStream memoryStream = new MemoryStream();

        memoryStream.Write(array, 0, array.Length);
        memoryStream.Position = 0L;
        MemoryStream memoryStream2 = new MemoryStream();

        StreamZip.Unzip(memoryStream, memoryStream2);
        string dirName = text.Substring(0, text.LastIndexOf("/"));

        if (!QFileUtils.ExistsDir(dirName))
        {
            QFileUtils.CreateDir(dirName);
        }
        if (!QFileUtils.Exists(text))
        {
            QFileUtils.CreateFile(text);
        }
        QFileUtils.WriteBytes(text, memoryStream2.ToArray());
    }
Exemplo n.º 3
0
    private static bool CopyDir(DirectoryInfo fromDir, string toDir, string rootDir)
    {
        string text = string.Empty;

        FileInfo[] files = fromDir.GetFiles();
        for (int i = 0; i < files.Length; i++)
        {
            FileInfo fileInfo = files[i];
            text = toDir + fileInfo.FullName.Substring(rootDir.Length);
            string dirName = text.Substring(0, text.LastIndexOf("\\"));
            QFileUtils.CreateDir(dirName);
            File.Copy(fileInfo.FullName, text, true);
        }
        DirectoryInfo[] directories = fromDir.GetDirectories();
        for (int j = 0; j < directories.Length; j++)
        {
            DirectoryInfo fromDir2 = directories[j];
            QFileUtils.CopyDir(fromDir2, toDir, rootDir);
        }
        return(true);
    }