How to creat a new list file?

This is a discussion on How to creat a new list file? within the C++ Programming forums, part of the General Programming Boards category; Hello: Suppose in one fold contains many files of *.txt or *.csv: A.csv, B.csv, C.csv .... I want to creat ...

  1. #1
    Registered User
    Join Date
    Sep 2011
    Posts
    12

    How to creat a new list file?

    Hello:

    Suppose in one fold contains many files of *.txt or *.csv: A.csv, B.csv, C.csv .... I want to creat a file, say named list.txt, it only lists the file names of the fold:
    A.csv
    B.csv
    C.csv
    .......
    .......

    Could you tell me what is the way to creat this list.txt file?

  2. #2
    Registered User hk_mp5kpdw's Avatar
    Join Date
    Jan 2002
    Location
    Northern Virginia/Washington DC Metropolitan Area
    Posts
    3,794
    What OS are you on? There are the opendir/readdir/closedir family of functions for one.
    "Owners of dogs will have noticed that, if you provide them with food and water and shelter and affection, they will think you are god. Whereas owners of cats are compelled to realize that, if you provide them with food and water and shelter and affection, they draw the conclusion that they are gods."
    -Christopher Hitchens

  3. #3
    Registered User
    Join Date
    Sep 2011
    Posts
    12
    Hi, Thanls for your reply.

    My OS is windowsXP.

    What is the way for this OS to creat a list.txt containing the file's names in this folder.

  4. #4
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,293
    I would consider just:
    changing the current directory if needed,
    using system to execute "dir /b", and
    redirect the output to file.
    My homepage
    Advice: Take only as directed - If symptoms persist, please see your debugger

    Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"

  5. #5
    Registered User
    Join Date
    Sep 2011
    Posts
    12

    Thanks!

    Quote Originally Posted by iMalc View Post
    I would consider just:
    changing the current directory if needed,
    using system to execute "dir /b", and
    redirect the output to file.
    Hi iMalc:

    Thank you so much! your way is simple and workable!
    --Zhao

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. error in creat file by using 'open' function
    By liuguobiao in forum Linux Programming
    Replies: 5
    Last Post: 03-23-2009, 10:59 AM
  2. How to creat header files
    By Shidlingayya in forum C Programming
    Replies: 1
    Last Post: 08-09-2007, 07:53 AM
  3. How to creat an array function?
    By salman86 in forum C++ Programming
    Replies: 1
    Last Post: 07-11-2005, 10:25 AM
  4. could not creat process?!
    By samiei in forum C Programming
    Replies: 11
    Last Post: 02-20-2005, 07:52 AM

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