关于学校项目的压缩文件的问题 [英] Question about compressed files for school project

查看:94
本文介绍了关于学校项目的压缩文件的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这里需要一些建议:



我有一个学校项目,我需要学习如何打开读取和写入压缩文件到计算机上的目录>



所以,我的代码远远不够。



Need some advice here:

I have a school project where I need to learn how to open read and write a compressed file to a directory on the computer>

So, far I have got this far with my code.

#include <iostream>

#include <fstream>

#include <iomanip>

#include <ostream>

#include <string>

using namespace std;

int main(void){

   ofstream ofile;

   // Opening file for writing

   ofile.open ("master.rez");

   if(ofile.is_open()){

   std::cout << ofile << "this line will be written into master.rez."<< endl;

   std::cout << ofile << "this line also will be written into master.rez."<<  endl;

   system("pause");

      ofile.close();

   }else{

      cerr<<"Error opening file!!"<<endl;

   }

   string buf;

   // Opening file for reading

   ifstream ifile;

   ifile.open("master.rez");

   if(ifile.is_open()){

      while(getline(ifile,buf))

      cout<<buf;

      ifile.close();

   }else{

      cerr<<"Error opening file!!"<<endl;

   }

   return 0;

}





所以,有我的代码我可以打开压缩文件并读取然后打开它再次使用ifstream并将整个压缩文件写入我的目录,但我需要能够读取压缩文件中的所有文件,然后使用ifstream将所有文件从压缩文件写入目录,如提取他们。



为了做到这一点,我现在需要采取的步骤是什么。



而且,对于未来的术语,如果我想用任何压缩文件类型执行此操作,只要它未加密的方式和步骤也是如此,我需要感谢。我非常感谢任何帮助。



我尝试过:



我已经让我的程序打开读取并将整个master.rez文件写入我的目录,其中存储了exe但我需要能够打开压缩的master.rez文件并读取它将压缩文件内的所有文件master.rez写入我存储exe的目录。



So, there is my code I can open the compressed file and read it then open it again with "ifstream" and write the whole compressed file to my directory but I need to be able to read all the files inside of the compressed file and then use "ifstream" to write all the files from the compressed file to the directory like extracting them.

What, is the steps I need to take now in order to do this.

And, also for future terms if I wanted to do this with any compressed file type as long as its not encrypted how and what are the steps for that as well That I need to take thanks. Any help I get is gratefully appreciated.

What I have tried:

I've, got my program to open read and write the entire "master.rez" file to my directory where the "exe" is stored but I need to be able to open the compressed "master.rez" file and read it and write all the files inside of the compressed file aka "master.rez" to my directory where my "exe" is stored.

推荐答案

首先查看ZipFile类:如何:压缩和提取文件Microsoft Docs [ ^ ]
Start by looking at the ZipFile class: How to: Compress and extract files | Microsoft Docs[^]


这篇关于关于学校项目的压缩文件的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆