How can I copy and paste a file in Windows using C++?

后端 未结 6 1724
慢半拍i
慢半拍i 2021-01-18 02:15

I have googled this, but I am still confused about how to use it. I am making a file manager, and I want to be able t o copy and paste a file into a new directory. I know

6条回答
  •  情书的邮戳
    2021-01-18 02:22

    void copyFile(const std::string &from, const std::string &to)
    {
        std::ifstream is(from, ios::in | ios::binary);
        std::ofstream os(to, ios::out | ios::binary);
    
        std::copy(std::istream_iterator(is), std::istream_iterator(),
              std::ostream_iterator(os));
    }
    

提交回复
热议问题