how to search for a file using C?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • poolboi
    New Member
    • Jan 2008
    • 170

    how to search for a file using C?

    hi all,

    i've got a long long program that does deletion in excel file
    but this excel files get it's information from a text file

    i would like to automate things a little here
    wondering if there's any way where i could search for the file in a particular directory?
    cos my current program requires me to manually key in the name of my file that i'm getting my data from

    i'm using C in windows
    thanks
    :)
  • gpraghuram
    Recognized Expert Top Contributor
    • Mar 2007
    • 1275

    #2
    Originally posted by poolboi
    hi all,

    i've got a long long program that does deletion in excel file
    but this excel files get it's information from a text file

    i would like to automate things a little here
    wondering if there's any way where i could search for the file in a particular directory?
    cos my current program requires me to manually key in the name of my file that i'm getting my data from

    i'm using C in windows
    thanks
    :)

    Usually searching for a file in the system involves scripting like perl or Shell script and it works very well.
    So you can have a wrapper script to search for the file and pass that as argument to the C Executable
    Raghuram

    Comment

    • poolboi
      New Member
      • Jan 2008
      • 170

      #3
      yeah i know of perl and stuff
      but i've got a script already in mostly C
      dun wanna mess it up which why i'm trying to figure out if in C i can just detect a file automatically using C language so that the program will go to that file and get its data?
      so any ideas?

      Comment

      • gpraghuram
        Recognized Expert Top Contributor
        • Mar 2007
        • 1275

        #4
        Originally posted by poolboi
        yeah i know of perl and stuff
        but i've got a script already in mostly C
        dun wanna mess it up which why i'm trying to figure out if in C i can just detect a file automatically using C language so that the program will go to that file and get its data?
        so any ideas?

        I havent done anything of this sort, so i think other members can help u
        Raghuram

        Comment

        • poolboi
          New Member
          • Jan 2008
          • 170

          #5
          ok, thanks a lot anyway
          anyone who knows? help appreciated

          Comment

          • mac11
            Contributor
            • Apr 2007
            • 256

            #6
            Originally posted by poolboi
            ok, thanks a lot anyway
            anyone who knows? help appreciated
            I've use c in linux to search for a file inside a folder. I'm not sure if it applies to windows land or not but if your stuck maybe it's worth your time to see if you have opendir() and readdir() calls available.

            Here is a page that explains them:

            Comment

            Working...