how to list files in a directory with a certain name

How can I list files in a directory starting by something and put the names
in an wchart_t array.
For instance I have in my directory the following files :

R0SampFingerPic.raw
R1SampFingerPic.raw
R2SampFingerPic.raw
R3SampFingerPic.raw
R4SampFingerPic.raw
L0SampFingerPic.raw
L1SampFingerPic.raw
L2SampFingerPic.raw
L3SampFingerPic.raw
L4SampFingerPic.raw
blabla.txt
bldlsdls.dat

and i want to write a function that list only the files with a SampFingerPic
string.


FindFiles(L"*SampFingerPic.raw");

While I am at it, is it possible to use regexp for this function ?


0
tricubes (61)
1/5/2004 10:38:01 AM
vc.mfc 33608 articles. 0 followers. Follow

3 Replies
360 Views

Similar Articles

[PageSpeed] 50

    Take a look at the CFileFind    MFC class

-- 
Cheers
Check Abdoul [VC++ MVP]
-----------------------------------

"mosfet" <tricubes@wanadoo.fr> wrote in message
news:btbemb$j3o$1@news-reader1.wanadoo.fr...
> How can I list files in a directory starting by something and put the
names
> in an wchart_t array.
> For instance I have in my directory the following files :
>
> R0SampFingerPic.raw
> R1SampFingerPic.raw
> R2SampFingerPic.raw
> R3SampFingerPic.raw
> R4SampFingerPic.raw
> L0SampFingerPic.raw
> L1SampFingerPic.raw
> L2SampFingerPic.raw
> L3SampFingerPic.raw
> L4SampFingerPic.raw
> blabla.txt
> bldlsdls.dat
>
> and i want to write a function that list only the files with a
SampFingerPic
> string.
>
>
> FindFiles(L"*SampFingerPic.raw");
>
> While I am at it, is it possible to use regexp for this function ?
>
>


0
CheckAbdoul
1/5/2004 2:46:40 PM
Oups sorry I forgot to say that I am developping under Windows CE and that
class is not supported...

"CheckAbdoul" <checkabdoul at mvps dot org> a �crit dans le message de
news:%23mJMer50DHA.716@TK2MSFTNGP12.phx.gbl...
>     Take a look at the CFileFind    MFC class
>
> -- 
> Cheers
> Check Abdoul [VC++ MVP]
> -----------------------------------
>
> "mosfet" <tricubes@wanadoo.fr> wrote in message
> news:btbemb$j3o$1@news-reader1.wanadoo.fr...
> > How can I list files in a directory starting by something and put the
> names
> > in an wchart_t array.
> > For instance I have in my directory the following files :
> >
> > R0SampFingerPic.raw
> > R1SampFingerPic.raw
> > R2SampFingerPic.raw
> > R3SampFingerPic.raw
> > R4SampFingerPic.raw
> > L0SampFingerPic.raw
> > L1SampFingerPic.raw
> > L2SampFingerPic.raw
> > L3SampFingerPic.raw
> > L4SampFingerPic.raw
> > blabla.txt
> > bldlsdls.dat
> >
> > and i want to write a function that list only the files with a
> SampFingerPic
> > string.
> >
> >
> > FindFiles(L"*SampFingerPic.raw");
> >
> > While I am at it, is it possible to use regexp for this function ?
> >
> >
>
>


0
tricubes (61)
1/5/2004 5:04:57 PM
Mosfet,

Here is some code that I use to gather information about the number of
files, folders, and size of the files in a path.  You can pass in wild
cards, but it is not regexp.  Anyway, is an example...  It won't compile
since there are some other functions that are not included here, but you can
see how the loop works.

  :)

//
// Count the total file sizes and number of files in a tree
// Call: FilepathBlocks(filespec);
// Return: blocks total (each block is 2048 bytes)
//
DWORD FilepathBlocks(LPCTSTR Path, DWORD* pFiles, DWORD* pDirs, int level)
{
 static DWORD nBlocks;
 static DWORD nFiles;
 static DWORD nDirs;
 static CString pattern;
 static bool bFirstTime; // set if there no pattern on the first time
through
 static bool bPattern; // set to try again at level 0 when not *.*
 bool bFoldersOnly;  // set to do folders only
 CString csPath;
 LONGLONG fsize;
 HANDLE handle;
 WIN32_FIND_DATA fdata;
 csPath = Path;
 bFoldersOnly = false;

 if(g_bCancelFileScan)
  return 0L;

 if (level == 0) {
  // collect any pattern that might be there
  pattern = Path;
  if (pattern.FindOneOf("*?") != -1) {
   bFirstTime = false;
   bPattern = true;
   pattern = GetFileOnly(pattern);
   pattern = AddPathAndFile(BACK_SLASH,pattern);
   CString cs1 = pattern;
  }
  else {
   bPattern = false;
   bFirstTime = true;
   pattern = "\\*.*";
  }
  nBlocks = nFiles = nDirs = 0;
 }

 do {
  if ((handle=FindFirstFile(csPath, &fdata)) != INVALID_HANDLE_VALUE) {
   CWaitCursor wc;
   // process all entries
   do {
    // ignore ..
    if (_tcscmp(fdata.cFileName, "..") == 0)
     continue;
    // ignore also
    if (_tcscmp(fdata.cFileName, ".") == 0) {
     continue;
    }
    if ((fdata.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY) != 0) {
     CString cs;
     cs = csPath;
     // remove the wildcards if there
     if (cs.FindOneOf("*?") != -1) {
      cs = cs.Left(cs.ReverseFind('\\')+1);
      // we got wildcards so we never need this again
      bFirstTime = false;
     }
     // don't count the first folder if it was passed in with no wildcards
     if (!bFirstTime)
      ++nDirs;
     // it was a dir, recurse
     FilepathBlocks(cs+(bFirstTime?"":fdata.cFileName)+pattern, NULL, NULL,
level+1);
    }
    else if (!bFoldersOnly) {
     fsize = fdata.nFileSizeHigh*((LONGLONG)ULONG_MAX+1) +
fdata.nFileSizeLow;
     // it was a file, count the size
     nBlocks += (DWORD)(fsize/2048 + ((fsize%2048)?1:0));
     ++nFiles;
    }
//    GiveTime();
   } while (FindNextFile(handle, &fdata) && !g_bCancelFileScan);
   FindClose(handle);
  }
  if (bPattern && !bFoldersOnly) {
   // let's expand folders in this folder, we didn't find any file matches
   bFoldersOnly = true;
   // strip the wildcards
   csPath = csPath.Left(csPath.ReverseFind('\\')+1);
   csPath += "*.*";
  }
  else {
   // we're done doing the folder pass
   bPattern = false;
  }
 } while (bPattern);
 if (pFiles)
  *pFiles = nFiles;
 if (pDirs)
  *pDirs = nDirs;
 return nBlocks;
}

Tom
"mosfet" <tricubes@wanadoo.fr> wrote in message
news:btbemb$j3o$1@news-reader1.wanadoo.fr...
> How can I list files in a directory starting by something and put the
names
> in an wchart_t array.
> For instance I have in my directory the following files :
>
> R0SampFingerPic.raw
> R1SampFingerPic.raw
> R2SampFingerPic.raw
> R3SampFingerPic.raw
> R4SampFingerPic.raw
> L0SampFingerPic.raw
> L1SampFingerPic.raw
> L2SampFingerPic.raw
> L3SampFingerPic.raw
> L4SampFingerPic.raw
> blabla.txt
> bldlsdls.dat
>
> and i want to write a function that list only the files with a
SampFingerPic
> string.
>
>
> FindFiles(L"*SampFingerPic.raw");
>
> While I am at it, is it possible to use regexp for this function ?
>
>


0
tserface (3861)
1/5/2004 5:12:14 PM
Reply:

Similar Artilces:

Customizing Activities\History LIst
Is there a way to add a date to Activities' History list? It would be nice to know when each activity happened. Thanks, Troy Troy, no way currently, although Microsoft has mentioned it might be an option in version 2.0 (nothing is guaranteed!) A few ISVs have custom products that do it... www.salentica.com www.c360.com Dave "Troy" <anonymous@discussions.microsoft.com> wrote in message news:af6b01c436bd$ce671f00$a001280a@phx.gbl... > Is there a way to add a date to Activities' History > list? It would be nice to know when each activity > happened. >...

Better to "nest" or use multi-level list?
I'm in the process of creating/defining a style(s) for a list that will be numbered in "level 1" and have indented bullets in "level 2." For such a list is it better to define a multi-level list style and linked paragraph styles? Or use one's already defined numbered list and use one of the Word's pre-defined bullet lists when needed for the second level? As part of this question, is is preferable not to have a style "nested" within another style or doesn't it matter? Thank you. -- Norm Hi Norm: I'm not sure why yo...

Distribution List Changes
Hi All, I have a mail enabled distribution list with four users. Only those users plus the Administrator have rights on this group. Yet a seperate user is able to add / edit or remove users to this group even though they do not belong to this group. The user does not even have admin rights and is able to make changes. Let me know of any options I can try. Thanks Waynear wrote: > Hi All, > > I have a mail enabled distribution list with four users. Only those > users plus the Administrator have rights on this group. > > Yet a seperate user is able to add / edit or remov...

Sound shows on custom Annimation list yet no sound heard
When the PP Presentation is saved as a show,some slides have sound and some do not. All sound came from the same folder. Also, when playing the slides while in PPPresentation, swome have sound and some do not despite all being indicated on custom annimation lisy and all startin "after previous." Thanks! Often when one sound plays but another doesn't, it's an issue of the length of the file path. What's the file path to your music? Is it really long? If so, the longer-named songs might just be hitting the length limit. -- Echo [MS PPT MVP] http://www.ec...

Shared file links not updated when rows inserted in subfiles
We have one shared file which receives data from 20 subfiles via links with a relative reference. User A will open subfile 1 with the shared file. User B will open subfile 2 with shared file. User A inserts a row in subfile 1. User A saves subfile 1 and shared file. User B saves subfile 2 and shared file. Either user opens shared file. Link in shared file does not recognize the inserted row from subfile 1. Help! ...

Drop Down List and Check Box
Hi...I was search for this topic but don`t found the solve...Anyway I have a drop down list like this [image: http://www.geocities.com/augurtrade/excel_checkbox.txt] and this [image: http://www.geocities.com/augurtrade/excel_checkbox2.txt] ok my questions is what is (Blanks) and (NonBlanks)...? Is it possible for me to see only all the check box that was checked or vice versa...??? How to make a total below the checkbox i mean when someone check the check box, a total number appear below the last check box [image: http://www.geocities.com/augurtrade/excel_checkbox3.txt] [image: http://www.g...

how reliable is the "Who has you in their contact list" list?
Because someone who I think has recently (within the last week) deleted me is still on this list (I don't think she blocked me), but when I check who deleted me on blockstatus.com, he shows up. could it be it's not updated? which of the two would be more reliable? -- maykk Greetings, Do not use these websites, they will steal your identity and sell it. You should change your password immediately. That said, in general, the "who has..." list within Messenger is accurate. There have been instances over the last six-months or so where the list (and m...

Problem restoring back up file on Money 2004
I had a problem with my PC and have had to reinstall my version of Money on a new PC. When I went to restore backup of data file I got the message "The File name is invalid. Please use a valid file name". the back up file name is "john1 current.mny". which is the extension that money would have given this file. I Had this problem before and a work colleague sorted by dowloading an update to my original restored software. ....Any ideas what this might have been ? You have to let Money go find it's own updates. Recommended method is to navigate to sample.mny, dou...

Change default file location
WHere and how do you change the default location for the Outlook PST file. I appreciate you help. Johnny Moore Moore-WDS Close Outlook. Move your PST file. Re-open Outlook and tell Outlook where you moved it when it asks. -- Russ Valentine [MVP-Outlook] "moore-wds" <anonymous@discussions.microsoft.com> wrote in message news:0b6301c3b447$80ae9a70$a001280a@phx.gbl... > WHere and how do you change the default location for the > Outlook PST file. I appreciate you help. > > Johnny Moore > Moore-WDS >WHere and how do you change the default location for the &g...

Selecting from contacts list
I have all my contacts in the Contacts List and I want to delete all those with a common extension i.e. all those who have email addresses @hotmail. I am using Outlook 2007 Can you do a search or advanced search which will show the contact you want to delete? You should be able to highlight & delete them from the results. "GrahamC" <GrahamC@discussions.microsoft.com> wrote in message news:6AC1880D-9632-4ED9-BAE2-7083690B9FA7@microsoft.com... > I have all my contacts in the Contacts List and I want to delete all those > with a common extension i.e. all t...

Can worksheet data be exported/imported to/from flat file?
We have a software product which does structured data storage and retrieval of application data to and from the database. (Like almost any other application - nothing new here.) To allow customers to do ad-hoc extensions, we have a module which allows them to integrate their own spreadsheets. Alternatively, the client may contract with us to develop custom spreadsheets for them. This allows us to quickly integrate custom 'interfaces' with our app, according to each customer's needs. The problem with this, is that the 'code' (in our context VBA) is stored repetitively with ...

Unable to open this file
On opening a linked spreadsheet I get the message "unable to open this file". However, when I open the file in question it opens OK and, of course, then I can update the link. Any ideas why the link wont work but opening direct will? Thanks. Bill Ridgeway Hi, Here is some information which may apply to your case http://support.microsoft.com/kb/823026/en-us If this helps, please click Yes -- Thanks, Shane Devenshire "Bill Ridgeway" wrote: > On opening a linked spreadsheet I get the message "unable to open this > file". However, when I open ...

How do I open a file from Publisher 2002 using Publisher 2000?
I received a file attachment via e-mail that was created with Publisher 2002. I have Publisher 2000, and I get an error message that I can't open a different version. How do I open the file? Allanteguy <Allanteguy@discussions.microsoft.com> was very recently heard to utter: > I received a file attachment via e-mail that was created with > Publisher 2002. I have Publisher 2000, and I get an error message > that I can't open a different version. How do I open the file? You find someone with Publisher 2002 or 2003 and get them to go to File > Save As, and select ...

Script to list access right
Hi I am trying to find any script which would generate list of login users with certain access level (select, write etc.) at one particular database. Is there something like that? Thanks. Justin ...

a list of lists
currently i use CArray to keep track of a list of objects, but I don't know MFC classes well enough to keep track of a list of lists. I'd appreciate some suggestions "wanwan" <ericwan78@yahoo.com> ha scritto nel messaggio news:1187535523.924671.143350@j4g2000prf.googlegroups.com... > currently i use CArray to keep track of a list of objects, but I don't > know MFC classes well enough to keep track of a list of lists. I'd > appreciate some suggestions You might want to embedd your list based on CArray into a class (e.g. CListOfSomething), and then ...

Smart List export to Excel #2
Hi, We are using Dynamics 9.0 and Office 2003. When we try to do a Smart List export to Excel, we keep getting an "Exception_Class_Object_Exception" that references varying object errors, such as 'Cells' or 'Value'; the object errors will change each time we try an export. As a workaround, I've found that closing Excel before doing the export allows the export to complete successfully. However, that solution isn't acceptable, as our Dynamics users would like to be able to work in Excel, doing other tasks, while the export is processing. Does anyone...

List of different values in data area
Hi excel specialists, How Can I automatically get the list of different values from the dat area and to find out their frequence? INDIVIDUALLY MEASURED VALUES: 3,5 4 3,5 4 3 3,5 4 4 3 3,5 4 3 3,5 3 3 3,5 4 4 Thanks for your help in advance. Balcovja -- balcovj ----------------------------------------------------------------------- balcovja's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=2623 View this thread: http://www.excelforum.com/showthread.php?threadid=39572 Take a look at FREQUENCY in Hep -- HTH RP (remove nothere from the email address if m...

sending exe files
What security settings do I have to change in XP to be able to send exe files via outlook?? I need to send exe files with the extension .exe "Vanguard" <rztqf6v02-NIX@sneakemail-NIX.com> wrote in message news:OSmxGCHXDHA.2392@TK2MSFTNGP10.phx.gbl... > "Randy" <randy@nwinds.com> wrote in message > news:eMCP5%23GXDHA.3248@tk2msftngp13.phx.gbl > > What security settings do I have to change in XP to be able to send > > exe files via outlook?? > > Rename the extension. > > -- > ____________________________________________________...

Global Address List and Handhelds
We use Ipaqs throughout the company, and I was wondering if there is anyway to have exchange add the GAL to the outlook contacts on the workstation, so that when they sync up, they will retrieve the Global Address List? In news:%23TkYtT0$GHA.3560@TK2MSFTNGP04.phx.gbl, Flip <phil.atkinson@beltek.com> typed: > We use Ipaqs throughout the company, and I was wondering if there is > anyway to have exchange add the GAL to the outlook contacts on the > workstation, so that when they sync up, they will retrieve the Global > Address List? No (and this wouldn't really be an ...

Fields in items list-- add/delete
Hai, I am using RMS version 1.2. In Stores Operations Manager it displays list of items when click on Database-->Items. It displays only five columns. Now i need to add / delete some fields in this list. Is it possible to add or delete the fields? if yes how can i add the fields? Thanks in advance, Nagendra On Wed, 27 Apr 2005 01:22:02 -0700, "Nagendra" <Nagendra@discussions.microsoft.com> wrote: >Is it possible to add or delete the fields? if yes how can i add the fields? I don't think so antonio ...

store name on z report
hi every body any one knows how to add the store name to the z report using receipt format xml thanks -- maher almasri This is a multi-part message in MIME format. ------=_NextPart_000_0151_01CB1476.D576A4D0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable maher, Change the Logo section to this, = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D Logo = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D --> =20 <PICTURE> ...

remove small list from large list
I have two mail lists on excel. The first has 16,000 names, the second has about 6,000. I need to remove the 6,000 from the 16,000 as they all appear in the big list as well. How do I extract those 6,000 entries from the larger list? My expected result is a mailing list with 10,000 names. Chip Pearson has some techniques at: http://www.cpearson.com/excel/duplicat.htm Howie J. wrote: > > I have two mail lists on excel. The first has 16,000 names, the second has > about 6,000. I need to remove the 6,000 from the 16,000 as they all appear > in the big list as well. How do ...

VC Application to access network path file
Hi, all I have a question, my boss told me to write a application to run in a computer to access a file saved in a netwok path, but the computer do not have the permission to access that remote path, my boss's suggestion is : the App can create a connection by sending valid username and password ,and then can access that remote file. but the computer always can not access that network path. could anybody give me some helpful suggestions, thanks in advance! -jos I think your boss tolds you to use WNetAddConnection2. -- WebSite : Realization of Dream { imagine your dream} ...

format of numbers in a downloaed file
I have a peculiar (atleast to me) problem,. I get some bills account from my consultant. This is not in a webpage nor as an email message nor as an attachment to an email message. I get these bills in the special software which he has introduced in my computer. But when I < selectall> the entries in the file and copy to an excel spreadsheet it serves the prupose mostly. But some numbers are in a strange format neither as numbers, nor as text but in some format such that I am not able to do calclations on these "numbers". I know how to convert a number in text format into num...

File Conversion From Money 2002 to Money 2004
Hi I have been using Money 2002 Standard Edition for quite some time now and I have just recently brought Money 2004 Deluxe Edition. I have Installed the 2004 edition and tried to convert the 2002 version and when it tries to convert the file it comes with an error message "Money was unable to open this file because it was created with an Incompatible version". Yet I am able to convert a money file that I use to use with money 98. Can anyone explain why? You have to stick within region when upgrading. US > US or UK > UK is OK but UK > US is a non-no. BTW if you have...