回 帖 发 新 帖 刷新版面

主题:在vc++ 6.0中如何实现拷贝目录?

在vc++ 6.0中如何实现拷贝目录中的所有文件以及子目录到另外一个目录,有没有这样的函数呢?请高手指点

回复列表 (共6个回复)

沙发

有,SHFileOperation用这个API就可以了

板凳

#include <iostream>
#include <string>
#include <fstream>
using namespace std;
int main()

 const int bufSize = 1024; 
 string s;
 cout<<"please input a file pathname:"; 
 cin>>s; 
 ifstream from(s.c_str(), ios_base::binary);
  if(!from) 
 {  
     cout<<"cannot open the file:"<<s<<endl;  
     return 0; 
 }
 cout<<"please input a file new pathname:"; 
cin>>s; 
ofstream to(s.c_str(), ios_base::binary); 
if(!to) 
 {  
  cout<<"cannot open the file:"<<s;  
  return 0; 
 }
 char buf[bufSize];
 int inBytes; 
  do
 {  
   from.read(buf, bufSize);
   inBytes = from.gcount();
   to.write(buf, inBytes); 
  }while(inBytes == bufSize);
  from.close(); to.close();
  system("pause"); 
 return 0;
}


//Trackback: http://tb.blog.csdn.net/TrackBack.aspx?PostId=755467

3 楼

#include <iostream>
#include <string>
#include <fstream>
using namespace std;
int main()

 const int bufSize = 1024; 
 string s;
 cout<<"please input a file pathname:"; 
 cin>>s; 
 ifstream from(s.c_str(), ios_base::binary);
  if(!from) 
 {  
     cout<<"cannot open the file:"<<s<<endl;  
     return 0; 
 }
 cout<<"please input a file new pathname:"; 
cin>>s; 
ofstream to(s.c_str(), ios_base::binary); 
if(!to) 
 {  
  cout<<"cannot open the file:"<<s;  
  return 0; 
 }
 char buf[bufSize];
 int inBytes; 
  do
 {  
   from.read(buf, bufSize);
   inBytes = from.gcount();
   to.write(buf, inBytes); 
  }while(inBytes == bufSize);
  from.close(); to.close();
  system("pause"); 
 return 0;
}

4 楼


int copyFiles(char *strFromPath,char *strToPath)
{
    typedef int (WINAPI ICEPUB_COPYFILES)(char *strFromPath,char *strToPath);
    ICEPUB_COPYFILES *icePub_copyFiles = 0;
    HINSTANCE hDLLDrv = LoadLibrary("icePubDll.dll");
    if(hDLLDrv)
    {
        icePub_copyFiles = (ICEPUB_COPYFILES *)GetProcAddress(hDLLDrv, "icePub_copyFiles");
    }

    icePub_copyFiles(strFromPath,strToPath);

    if(hDLLDrv)
        FreeLibrary(hDLLDrv);

    return 0;
}



//http://icese.net/read.php?tid=8499
//可下icePubDll.dll

5 楼

玩农场,玩游戏,不如来玩能赚钱的农场:
全国首创巨大的偷菜赚钱,寻宝赚钱..等等
两类玩家--推广员和免费的玩家
永久免费--任何一个玩家免费玩
寻宝系统--每日10万元现金分享
魔法系统--结出金锭兑现现金
结婚系统--相互关爱,体验爱情
养育系统--上线拥有孩子打招呼
聊天系统--独一无二的聊天系统
届时欢迎团队领导人,抢占高位,抢占先机..
了解没损失,选择很重要,赚钱有方法
 联络QQ908889846  
事业者请浏览http://www.thxt999.com/Member.asp?u_id=cdc666
免费玩奇迹农场:首先打开摩客奇迹农场官方游戏网站.   http://www.ga-me.hk/ 点马上注册.  ID号码是六位数以上的字母和数字组合的都可以.推广员ID号写我的ID cdc666 

6 楼

你好.我是全职网赚工作者.
如果你有时间有电脑.会打字.
想在网络上创业.请联系我..
项目绝对真实.详情QQ空间资料
加盟请联系 QQ908889846

我来回复

您尚未登录,请登录后再回复。点此登录或注册