Example #1
0
        // --- 导出文件夹 ---
        /// <summary>
        /// 将节点数据解包到文件夹
        /// </summary>
        /// <param name="Dir">目的文件夹</param>
        /// <param name="Node">节点</param>
        private void exportFloder(DirectoryInfo Dir, TreeNode Node)
        {
            FCYResPackageNode tNode = (FCYResPackageNode)Node.Tag;

            // 文件夹节点
            if (tNode.IsFloder())
            {
                // 创建文件夹
                DirectoryInfo tOut = Directory.CreateDirectory(Dir.FullName + "\\" + tNode.Name);
                // 遍历
                foreach (TreeNode x in Node.Nodes)
                {
                    exportFloder(tOut, x);
                }
            }
            else // 文件节点
            {
                // 准备文件
                FileStream tOutput = new FileStream(Dir.FullName + "\\" + tNode.Name, FileMode.Create, FileAccess.ReadWrite, FileShare.Read);

                FCYResPackageDataNode tDataNode = (FCYResPackageDataNode)tNode;

                // 直接写出
                tDataNode.ExtractStreamTo(tOutput);

                // 关闭
                tOutput.Close();
            }
        }
Example #2
0
        // --- 导出流 ---
        private void toolStripButton_Export_Click(object sender, EventArgs e)
        {
            if (tabControl_Data.Tag != null)
            {
                FCYResPackageNode tTempNode = ((FCYResPackageNode)((TreeNode)tabControl_Data.Tag).Tag);
                if (tTempNode.IsFloder())
                {
                    return;
                }

                FCYResPackageDataNode tData = (FCYResPackageDataNode)tTempNode;

                if (tData.DataRealSize == 0)
                {
                    showErr("节点无数据。");
                    return;
                }
                saveFileDialog2.FileName = tData.Name;
                if (saveFileDialog2.ShowDialog() != DialogResult.Cancel)
                {
                    FileStream tOut = new FileStream(saveFileDialog2.FileName, FileMode.Create);

                    tData.ExtractStreamTo(tOut);
                }
            }
        }