473,395 Members | 1,641 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Is there anyway to write a folders contents to file?

Is there anyway to write a folders contents to file?

-Frank B.

Oct 11 '06 #1
11 1628

Frank B. wrote:
Is there anyway to write a folders contents to file?
Depends on your OS. The simplest way is to use system(3)

system("ls >file");

in a C-Program (provided that there is an ls command on your system)

Most OSs implement opendir/readdir/closedir to parse a directory. Look
into your manuals.

Hubble.

Oct 11 '06 #2

Frank B. wrote:
Is there anyway to write a folders contents to file?

-Frank B.
Yes, use the function

PutTheListOfAllThingsInTheFolderIntoThisString(fol der,&string)

Be careful to allocate enough memory for string or the
DS2K will shoot you.

Now write string to a file (as this involves sending
a letter to China, this might take a while).

- William Hughes

Oct 11 '06 #3
Frank B. wrote:
Is there anyway to write a folders contents to file?
See this recent thread:
<http://groups.google.com/group/comp.lang.c/browse_frm/thread/1d905632c44e86b8/?hl=en#>

Also search Google's archive of this group. Regardless of whether
system() or another OS specific API (like readdir() under POSIX), is
used, the idea of directories and their manipulation is beyond the
scope of standard C and thus this group.

Oct 11 '06 #4
"Frank B." wrote:
>
Is there anyway to write a folders contents to file?
Here we deal with the C language. Your query has nothing to do
with that.

You may want to look into the use of zip and unzip. See:

http://www.info-zip.org/

--
Some informative links:
<news:news.announce.newusers
<http://www.geocities.com/nnqweb/>
<http://www.catb.org/~esr/faqs/smart-questions.html>
<http://www.caliburn.nl/topposting.html>
<http://www.netmeister.org/news/learn2quote.html>
<http://cfaj.freeshell.org/google/>

Oct 11 '06 #5
Yes it does. I'm trying to write a program in C which looks into a
directory and copies all the file names in that directory into a file.

Thx
CBFalconer wrote:
"Frank B." wrote:

Is there anyway to write a folders contents to file?

Here we deal with the C language. Your query has nothing to do
with that.

You may want to look into the use of zip and unzip. See:

http://www.info-zip.org/

--
Some informative links:
<news:news.announce.newusers
<http://www.geocities.com/nnqweb/>
<http://www.catb.org/~esr/faqs/smart-questions.html>
<http://www.caliburn.nl/topposting.html>
<http://www.netmeister.org/news/learn2quote.html>
<http://cfaj.freeshell.org/google/>
Oct 11 '06 #6
"Frank B." <ke*********@gmail.comwrites:
Is there anyway to write a folders contents to file?
C has no concept of "folders".

If you post this question to a newsgroup that deals with whatever
platform you're using, be sure to explain just what you mean by
"contents". It could mean a list of file names, the contents of the
files themselves, or something else.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Oct 11 '06 #7
Frank B. wrote:
CBFalconer wrote:
"Frank B." wrote:
>
Is there anyway to write a folders contents to file?
Here we deal with the C language. Your query has nothing to do
with that.

You may want to look into the use of zip and unzip. See:

http://www.info-zip.org/

--
Some informative links:
<news:news.announce.newusers
<http://www.geocities.com/nnqweb/>
<http://www.catb.org/~esr/faqs/smart-questions.html>
<http://www.caliburn.nl/topposting.html>
<http://www.netmeister.org/news/learn2quote.html>
<http://cfaj.freeshell.org/google/>

Yes it does. I'm trying to write a program in C which looks into a
directory and copies all the file names in that directory into a file.

Thx
As I and others have mentioned standard C has no concept of
directories. You'll have to use an extension. If your platform supports
it, a POSIX function like readdir() would be most portable. Otherwise
you'll have to use whatever your OS or C library offers.

Since this group discusses Standard C, posting to a more specific group
like comp.os.ms-windows or comp.unix.programmer would be preferable.

Finally please don't top-post as this skews the flow of the post's
content and renders it hard to read. See CBFalconer's useful sig. above
for more information.

Oct 11 '06 #8
Frank B. said:
Yes it does.
Does what?
I'm trying to write a program in C which looks into a
directory and copies all the file names in that directory into a file.
C has no concept of "directory". You are confusing "the C language" with
"features available on my platform". I suggest you ask your question in a
newsgroup devoted to your platform. On some platforms, there is *no*
answer, because some platforms don't have the concept of "directory". (They
have other ways to organise data.) On those platforms that do support the
concept of "directory", the specifics of the answer will vary depending on
the platform and the available libraries.

Try news:comp.unix.programmer or news:comp.os.ms-windows.programmer.win32 -
those two seem to be the most likely to meet your needs.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
Oct 11 '06 #9
"Frank B." <ke*********@gmail.comwrites:
CBFalconer wrote:
>"Frank B." wrote:
>
Is there anyway to write a folders contents to file?

Here we deal with the C language. Your query has nothing to do
with that.

You may want to look into the use of zip and unzip. See:

http://www.info-zip.org/

Yes it does. I'm trying to write a program in C which looks into a
directory and copies all the file names in that directory into a file.
Please don't top-post. Read these:
http://www.caliburn.nl/topposting.html
http://www.cpax.org.uk/prg/writings/topposting.php

(It took me a while to figure out what "Yes it does." refers to.)

Again, standard C has no concept of directories. There is no portable
solution to your problem. There is almost certainly a non-portable
solution that will work very well on your system. You need to ask in
a newsgroup that deals with whatever platform you're using.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Oct 11 '06 #10
On 11 Oct 2006 11:54:30 -0700, in comp.lang.c , "Frank B."
<ke*********@gmail.comwrote:
>Yes it does.
Presumably you mean the C language. Please don't top-post in CLC, it
makes posts meaningless. And I'm afraid you're wrong, as C doesn't
have any concept of directories - thats a feature of your OS.
I'm trying to write a program in C which looks into a
directory and copies all the file names in that directory into a file.
The only C way to do that is to use system() and invoke whatever
commadn your OS would use to list the objects in the folder and put
the output into a file.

--
Mark McIntyre

"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it."
--Brian Kernighan
Oct 11 '06 #11
Frank B. wrote:
Is there anyway to write a folders contents to file?
You really want comp.unix.programmer, or a newsgroup on whatever
operating system you happen to be targeting.
Oct 11 '06 #12

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

21
by: AES/newspost | last post by:
My understanding -- I'm not an expert -- is that on (some? many? all?) standard Internet servers a URL can point to a subdirectory name followed by a backslash, and that links to this URL will...
0
by: munif | last post by:
i wnat write a C++ program that would read from a CD and display information about files and folders in the given CD In simple words you would be performing a simple (ls -l) or (DIR /S) on the...
3
by: frekster | last post by:
All. I have a folder/files that I have added asp.net to have read/write/etc. privlidges via the properties of the folder/files and security tab. However, when I run my asp.net page, I still get...
2
by: Lee | last post by:
Hi, Is there a way to force VS2005 to copy the folders (and contents of those folders) that I created in the project to the bin/debug directories? I have a folder that includes xml files that...
1
by: vangasd | last post by:
Hi, This is Sasidhar. I would like to know how can I access Folders and its contents in Windows XP using C. I am using Turbo C++ 3.0 as a compiler. Which header files do i need to use for my...
2
kamill
by: kamill | last post by:
i need to write content of one text file into another text file. My code is working ,if i choose both files from same directory where my program reside..BUT,its not working if i select files from...
24
by: Bill | last post by:
Hello, I'm trying to output buffer content to a file. I either get an access violation error, or crazy looking output in the file depending on which method I use to write the file. Can anyone...
6
by: aagarwal8 | last post by:
Hi, I am trying to write the contents of a textbox to a file in binary format. My code looks like this... private void btnWriteToFile_Click(object sender, EventArgs e) { FileStream fs =...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.