Hi,
I have a small question.
How do I compute the number of files(which are specific such as .doc) in a directory in C++.
For example, if I have 10 files of type .doc format in a directory, how do I compute this value using C++.
Any help is appreciated.
Thanks!!
6 26870
Hi,
I have a small question.
How do I compute the number of files(which are specific such as .doc) in a directory in C++.
For example, if I have 10 files of type .doc format in a directory, how do I compute this value using C++.
Any help is appreciated.
Thanks!!
I think it depends on OS in which you are working.
If you are on Unix OS then
int i;
i = system(ls -l path/*.doc|wc -l); // here path sholud be complete path
// or path from current directory till the folder where you are
// looking for .doc files.
Regards,
Girish.
sicarie 4,677
Recognized Expert Moderator Specialist
I think it depends on OS in which you are working.
If you are on Unix OS then
int i;
i = system(ls -l path/*.doc|wc -l); // here path sholud be complete path
// or path from current directory till the folder where you are
// looking for .doc files.
Regards,
Girish.
And in Windows I would imagine it would implement the Win32 API.
I am using Windows.
I have gone through the link given above for windows, but could not understand it properly.
Do we have any other methods for it.
Thanks!!
You call FindFirstFile and then call FindNextFile until is doesnm;t find a file.
If you are looking for all of the files, then find the *.* file.
I think it depends on OS in which you are working.
If you are on Unix OS then
int i;
i = system(ls -l path/*.doc|wc -l); // here path sholud be complete path
// or path from current directory till the folder where you are
// looking for .doc files.
Regards,
Girish.
Hi Girish. Found this forum while searching for a similar problem.I'm working on linux and tried ur code it prints the count value on the console but the return value is 0 on success . I want to assign the count value to a variable, how is it done???
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: vic |
last post by:
Hello, Dean
Try this:
select distinct c1, c2 into #tmp_1 from t1
select count(*) as cnt from #tmp_1
drop table #tmp_1
With best regards.
|
by: DataFreakFromUtah |
last post by:
Hello!
No question here, just a procedure for the archive.
Search critera:
count records imported count data imported count number of rows
imported
count number of records imported record import count automatically
import
and count records prompt for number of records imported import count
auto-import records
autoimport records count records before and after
|
by: Don |
last post by:
I intermittently get a runtime Compilation Error that says 'The
compiler failed with error code 2000'. It appears that a DLL cannot
be found in the 'temporary asp.net files' directory.
The Detailed Compiler Output is at the bottom of this post.
This is a custom dll named UtilitiesINGR.dll that I put in the GAC. I
added a machine.config entry to instruct my app to use the GAC entry.
Now I need to remove the dll from the GAC so I can...
|
by: Shawn Mehaffie |
last post by:
I have an application I want to be able to:
1) Store user specifc settings in ther "My Documents".
2) Store some information in "All Users" document directory.
3) I also want to be able to access program files that are installed in the
"Program Files" directory.
How can I get these locations from within a VB application.
|
by: tranky |
last post by:
hi,
only one information,please...
how to count number of anonymous online users?
I use ASP.NET 2.0
thank u
tranky
| |
by: isabelle |
last post by:
hi, every body..
I have two program I couldn’t solve them
So, can any body help me. please!!
1-Write a program that accepts a character and count number of occurrences in a file.
The file should have some text, and the program count how many times the inputted character repeated in the file and prints the result on the screen.
(Hint: you have to use continue statement in your solution )
Sample input:
|
by: Mack |
last post by:
Hi all,
I want to write a program to count number of bits set in a number.
The condition is we should not loop through each bit to find whether
its set or not.
Thanks in advance,
-Mukesh
|
by: mfaisalwarraich |
last post by:
Hi Everybody,
I am using the following code to get the recordset of an external database.
Dim dbPatients As Database
Dim rsCountPatients As Recordset ' to count number of patients in a table
Const strDBPath = "C:\Patients.mdb" ' external database
Set dbPatients = OpenDatabase(strDBPath, False, True, ";PWD=abc")
|
by: jambonjamasb |
last post by:
I am wanting to create a report that summarises the number of items within a date range.
For example I have a FIELD called System_Change.
This is a drop down COMBOBOX that uses words like unix, polfs etc.
I know how to query a date range, but not how to count number of fields within this date range.
I would like the report to show date range filtered then list all changes and number of times they appear.
Thanks in advance anything...
|
by: jlt206 |
last post by:
This code <?php include("counter.php")?> on the webpage produces the count number. (function code below)
I want to place the current number into a variable $MemberNo or into a FormField to be sent via an email function.
But just can't figure it out.
<?
////////////////////////////////////////////////////////////
//
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |