zoukankan      html  css  js  c++  java
  • VC:文件复制(CFile类、文件对话框、edit控件)

    1、打开一个文件内的内容复制到另一个文件中:

    2、打开要复制的文件:

           CFileDialog dlg(TRUE,"*","",OFN_ALLOWMULTISELECT,NULL);

           if(IDOK==dlg.DoModal())

           {

                  CString str=dlg.GetPathName();

                  SetDlgItemText(IDC_EDIT1,str);

           }

    3、实施:

    void CCopyFileDlg::OnCopyfile()

    {

           // TODO: Add your control notification handler code here

           CString filename1="";

           CString filename2="";

           GetDlgItemText(IDC_EDIT1,filename1);

           CFileDialog dlg(false,"","",OFN_ALLOWMULTISELECT,NULL);

           if(IDOK==dlg.DoModal())

           {

                  filename2=dlg.GetFileName();

                  CFile file1;

                  CFile file2;

                  file1.Open(filename1,CFile::modeReadWrite);

                  file2.Open(filename2,CFile::modeCreate|CFile::modeReadWrite);

                  char * c;

                  c=new char[file1.GetLength()];

                  file1.Read(c,file1.GetLength());

                  file2.Write(c,file1.GetLength());

                  file1.Close();

                  file2.Close();

                  //delete c;

                  AfxMessageBox("文件复制成功");

           }

    }

  • 相关阅读:
    Centos7,PHP7安装swoole
    安装最新LAMP环境(CentOS7+PHP7.1.5+Mysql5.7)
    PHP7性能提升原因
    Git 图文教程
    centos下安装mongodb和php的mongo扩展
    linux如何把普通用户添加到sudo组
    Linux常用的三种软件安装方式
    PHP几个常用的概率算法
    java面向对象知识(上)
    linux中tar命令用法
  • 原文地址:https://www.cnblogs.com/shenchao/p/2725204.html
Copyright © 2011-2022 走看看