How to delete files in a sub directory

Discussion in 'C Programming' started by zhiwei wang, Oct 29, 2004.

  1. zhiwei wang

    zhiwei wang Guest

    I am new to dealing with the file system using C. And couldnt find
    anyone in my office to help me out. :(

    okay here is my questions.

    If I want to delete a file in a directory other than my working
    directory, I would construct a string look like this:
    str="../../foo/bar/foobar"
    add use "remove(str);" to delete this file. A lot of my work involves
    constructing the directory string, so I wonder if this is a common
    practice of deleting files in C. Do you guys have better ways of
    performing this task?

    Thank you.
     
    zhiwei wang, Oct 29, 2004
    #1
    1. Advertising

  2. zhiwei wang

    Mike Wahler Guest

    "zhiwei wang" <> wrote in message
    news:...
    > I am new to dealing with the file system using C. And couldnt find
    > anyone in my office to help me out. :(
    >
    > okay here is my questions.
    >
    > If I want to delete a file in a directory other than my working
    > directory, I would construct a string look like this:
    > str="../../foo/bar/foobar"
    > add use "remove(str);" to delete this file. A lot of my work involves
    > constructing the directory string, so I wonder if this is a common
    > practice of deleting files in C. Do you guys have better ways of
    > performing this task?


    That's the only way to do it with standard C.
    You could check your implementation's documentation to
    see if it offers nonstandard exensions for working with
    directories, if that would make things simpler for you.

    -Mike
     
    Mike Wahler, Oct 29, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. TJS
    Replies:
    1
    Views:
    539
    Eliyahu Goldin
    Jun 23, 2004
  2. Replies:
    4
    Views:
    378
    Jonathan N. Little
    Jan 26, 2007
  3. Ben
    Replies:
    2
    Views:
    937
  4. Lawrence D'Oliveiro

    Death To Sub-Sub-Sub-Directories!

    Lawrence D'Oliveiro, May 5, 2011, in forum: Java
    Replies:
    92
    Views:
    2,128
    Lawrence D'Oliveiro
    May 20, 2011
  5. Dirk Einecke
    Replies:
    8
    Views:
    191
    Robert Klemme
    Apr 19, 2004
Loading...

Share This Page