Thread: Help with moving a file

  1. #1
    Registered User
    Join Date
    Feb 2002

    Help with moving a file

    Hello, I'm writing a program that requires me to rename/move a file from a temporary directory and store it in the current directory that I'm currently working under (which will be different for different computers that the program will be running on)

    I've tried using the rename function in stdlib but i cannot get it to move to the proper directory. The rename function says that if the new file name given is in a different path than the old file name, it would move the file to the new location. I can rename the file, but I cannot get it to store in the current directory. I cannot specify the exact directory that i wish to store the file into, because that changes with each computer, like I said before. What I'd like it to do, is to store the file in the current directory (whatever it is) without me specifying it directly. I've tried not specifying any path (ie. just giving the file name) but that doesn't work, and I cannot find were the new file is stored.

    So I'm hoping that someone can help me out with this problem. I've tried searching the web, but I can't seem to find anything the would help me out. So any help that you guys can provide me will be greatly appreciated

    Thank you

  2. #2
    Registered User alex's Avatar
    Join Date
    Sep 2001
    Try prepending the filename with "./", this should indicate that you want to move to the current directory. If this doesn't work, use the function to get the current directory.


    P.S. There should also be a function that returns the path and name of the .exe file you are running, maybe this is what you wanted instead?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. opening empty file causes access violation
    By trevordunstan in forum C Programming
    Replies: 10
    Last Post: 10-21-2008, 11:19 PM
  2. Inventory records
    By jsbeckton in forum C Programming
    Replies: 23
    Last Post: 06-28-2007, 04:14 AM
  3. Making a LIB file from a DEF file for a DLL
    By JMPACS in forum C++ Programming
    Replies: 0
    Last Post: 08-02-2003, 08:19 PM
  4. System
    By drdroid in forum C++ Programming
    Replies: 3
    Last Post: 06-28-2002, 10:12 PM
  5. Need a suggestion on a school project..
    By Screwz Luse in forum C Programming
    Replies: 5
    Last Post: 11-27-2001, 02:58 AM