Thread: Copy files

  1. #1
    Registered User
    Join Date
    Oct 2004
    Posts
    1

    Copy files

    Hey all, i am a beginning C programmer (...) and i am writing a program for different pc's (all windows).

    I want to make sure a program is located in a specific directory, but i dont know in what directory it is saved. (understand? )

    So does someone know how i can search for a file, and copy (or move) it into a specific directory?

    Thanks a lot, Erik

  2. #2
    you can get the filename and location from
    with in the running program with,


    Code:
    TCHAR szProgramPath[MAX_PATH];
    GetModuleFileName(NULL, szProgramPath, MAX_PATH);

    or

    Code:
    #include <iostream>
    using namespace std;
    
    int main(int argc, char *argv[] )
    {
          cout << argv[0] << endl;
    }
    would display the location and filename of the
    program i believe, so you can use
    that however youd like.


    Once you use that command to locate the current directory and
    filename of your program, you can use it to make a copy
    somewhere else perhaps i guess, or this info might make it less
    nessassary for you to have the program any certian place.
    Last edited by JarJarBinks; 10-09-2004 at 07:54 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Copy files across a network
    By LiteIce in forum C# Programming
    Replies: 4
    Last Post: 10-23-2007, 06:32 AM
  2. Help with loading files into rich text box
    By blueparukia in forum C# Programming
    Replies: 3
    Last Post: 10-19-2007, 12:59 AM
  3. added start menu crashes game
    By avgprogamerjoe in forum Game Programming
    Replies: 6
    Last Post: 08-29-2007, 01:30 PM
  4. fopen vs. _open (for BIG image files)
    By reversaflex in forum C Programming
    Replies: 3
    Last Post: 04-01-2007, 12:52 AM
  5. reinserting htm files into chm help files
    By verb in forum Windows Programming
    Replies: 0
    Last Post: 02-15-2002, 09:35 AM