Open an unknown lonely file in a dir?

This is a discussion on Open an unknown lonely file in a dir? within the C++ Programming forums, part of the General Programming Boards category; Hi, How can I open a file in directory that that will be the only file in that directory but ...

  1. #1
    hakan
    Guest

    Open an unknown lonely file in a dir?

    Hi,
    How can I open a file in directory that that will be the only file in that directory but I woun't know the name of it?
    I want to open the file read it and delete it and an other application will put a new file there...
    Thanks. /H

  2. #2
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    What compiler/OS are you using? (It'll be non-standard functions to do that type of thing)
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  3. #3
    Peace
    Join Date
    Aug 2001
    Posts
    1,510
    For a standard (though hackish and slow) method, you could always attempt loading every combination of name (providing of course, that you know the file extension, and that we're assuming 8 character file names max) and checking for its existance.

    Actually I think theres a Win32 function that gets the file names in a directory and returns them in the form of a pointer to array of strings... Unfortunatly I cant seem to find it. Sorry.
    "There's always another way"
    -lightatdawn (lightatdawn.cprogramming.com)

  4. #4
    I lurk
    Join Date
    Aug 2002
    Posts
    1,361
    Look up FindFirstFile() and FindNextFile() on msdn.microsoft.com

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, 01:44 PM
  2. opening empty file causes access violation
    By trevordunstan in forum C Programming
    Replies: 10
    Last Post: 10-22-2008, 12:19 AM
  3. Can we have vector of vector?
    By ketu1 in forum C++ Programming
    Replies: 24
    Last Post: 01-03-2008, 05:02 AM
  4. Encryption program
    By zeiffelz in forum C Programming
    Replies: 1
    Last Post: 06-15-2005, 04:39 AM

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