writing a file to a different directory

This is a discussion on writing a file to a different directory within the C++ Programming forums, part of the General Programming Boards category; Hi, I was wondering if it was possible to get C++ to write a file to another directory, since it ...

  1. #1
    Registered User
    Join Date
    Jan 2003
    Posts
    20

    writing a file to a different directory

    Hi, I was wondering if it was possible to get C++ to write a file to another directory, since it normally writes to the same directory that the program is in?

    Thanks

  2. #2
    Registered User The Dog's Avatar
    Join Date
    May 2002
    Location
    Cape Town
    Posts
    788
    All you need to do is create the file in the directory you want.

  3. #3
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,662
    To be more specific: you can use absolute paths for your filenames (although platform dependant):
    Code:
    const char *fn = "C:\\mydir\\myfile.txt";
    Or, use _chdir()

    gg
    Last edited by Codeplug; 03-04-2003 at 09:01 PM.

  4. #4
    Registered User
    Join Date
    Jan 2003
    Posts
    20
    oh....I feel soo stupid now!! hehe, thx =o)

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. File transfer- the file sometimes not full transferred
    By shu_fei86 in forum C# Programming
    Replies: 13
    Last Post: 03-13-2009, 12:44 PM
  2. opening empty file causes access violation
    By trevordunstan in forum C Programming
    Replies: 10
    Last Post: 10-21-2008, 11:19 PM
  3. System
    By drdroid in forum C++ Programming
    Replies: 3
    Last Post: 06-28-2002, 10:12 PM
  4. simulate Grep command in Unix using C
    By laxmi in forum C Programming
    Replies: 6
    Last Post: 05-10-2002, 04:10 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21