Results 1 to 4 of 4

Thread: Getting directory from a path

  1. #1

    Thread Starter
    Fanatic Member Geespot's Avatar
    Join Date
    Oct 2001
    Location
    Birmingham, UK
    Posts
    577

    Getting directory from a path

    Hi,

    I have wrote a class that opens a file and reads information out of it, and i have the following function..

    Code:
    model.LoadModel("data\\file.txt");

    How can i determine the directory that file is in, is current applications path and \data\ " ?

    The reason is the file.txt contains a reference to another file, which is stored in the same path as file.txt. But i dont know how to code to find out what that directory is.


    Thanks.

  2. #2
    Lively Member
    Join Date
    May 2002
    Location
    Oregon
    Posts
    64
    Try searching for _splitpath on MSDN.

  3. #3
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    On windows you can use _getcwd to get the current working directory, to which all relative paths relate.

    There's a similar POSIX function.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  4. #4

    Thread Starter
    Fanatic Member Geespot's Avatar
    Join Date
    Oct 2001
    Location
    Birmingham, UK
    Posts
    577
    Thanks for your replies, helped me alot

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width