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?
Asked
Active
Viewed 1,155 times
1 Answers
1
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");
-
Thanks for the reply! The problem is that the file isn't in a folder already, it's non existant. It'd have to be from the program itself. – michealbell May 10 '15 at 02:02
-
Er, that doesn't really help me much. I want to take a file from my application itself and copy it to a directory – michealbell May 10 '15 at 02:06
-
Hmm, could you be a little more specific with the problem? Sorry, I thought I was on the same page. :/ – abuv May 10 '15 at 02:12
-
1It's fine, I'm probably not explaining it properly. So, I have my own dll c++ project, and I have an exe project. I'd like my exe application to copy my dll project and drop it in a directory. – michealbell May 10 '15 at 02:14
-
Cool, so the exe application needs to copy the dll project, and paste it to a directory of your choosing. Are you maybe looking for static linking? – abuv May 10 '15 at 02:20
-
It could be that, not 100 percent sure though. I remember that in vb.net you could have a file in "resources" and you could copy it to anywhere you like, I'd like something like that – michealbell May 10 '15 at 02:22
-
Well I hope it is! I'm not too familiar with vb so I can't say. If not, I apologize for bringing you this wall of text. Not what I intended to do. – abuv May 10 '15 at 02:27
-
It's alright, thanks for your replies :) hopefully I can find a solution somewhere else – michealbell May 10 '15 at 02:29