michealbell
michealbell

Reputation: 65

C++ Copy File to Directory From Resources?

Suppose I have an external dll file that I would like to drop to a directory, how can I add said file to "resources" and how can I copy and place it in a directory?

Upvotes: 1

Views: 1268

Answers (1)

abuv
abuv

Reputation: 167

What you would want to do is use the fstream library. Here is a previously answered question similar to yours.

From user CapelliC:

#include <fstream>

// copy in binary mode
bool copyFile(const char *SRC, const char* DEST)
{
    std::ifstream src(SRC, std::ios::binary);
    std::ofstream dest(DEST, std::ios::binary);
    dest << src.rdbuf();
    return src && dest;
}

int main(int argc, char *argv[])
{
    return copyFile(argv[1], argv[2]) ? 0 : 1;
}

Response/Edit- No problem! To make a new directory you can use mkdir once you add the direct.h library, as followed:

      mkdir("c:/myfolder");

Upvotes: 0

Related Questions