0

Hello all, my name is alfredo, and I am 13 years old. I just started learning c++ about 2 weeks ago, and I am having a problem that's really giving me a headache. I am trying to code a project that will contain 2 files, file1 and file2. When file1 is opened I want file2 to be copied to a specific directory,we can use C:\randomdir for this example, but when my app will be downloaded I don't know where the user is going to download it to. So doing what i had originally done, system("copy C:\downloads\file2 C:\randomdir'); will be pointless, since I don't know if they will download it to C:\downloads or C:\documents or even E:\ files, :( so I am really lost on what to do next, and any help will be much appreciated.

, Alfredo


p.s I have already googled, and searched through daniweb, thank you.

2
Contributors
1
Reply
2
Views
10 Years
Discussion Span
Last Post by Hamrick
2

You can find out where the exe is with command line arguments.

#include <iostream>

using namespace std;

int main( int argc, char *argv[] ) {
  cout<< argv[0] <<endl;
  return 0;
}

Once you have that string, you can trim off the filename and then have a path for storing the files. :)

Votes + Comments
cool solution
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.