Parsing directories

Thank you to all who helped with the "Select Directory" dialog. I'm
now faced with a new problem that I should have forseen. How do I get
all of the file names in this directory (where the path is represented
as a CString)?

Sorry if this isn't an MFC question.

Thanks,
-Mike-
0
guest (34)
2/21/2005 6:21:08 PM
vc.mfc 33608 articles. 0 followers. Follow

4 Replies
620 Views

Similar Articles

[PageSpeed] 3

Look at the splitpath function.

AliR.

"Debaser" <guest@unknown.com> wrote in message
news:hg9k11h2r2fv64rrsfghp1f40vm6al0cb5@4ax.com...
> Thank you to all who helped with the "Select Directory" dialog. I'm
> now faced with a new problem that I should have forseen. How do I get
> all of the file names in this directory (where the path is represented
> as a CString)?
>
> Sorry if this isn't an MFC question.
>
> Thanks,
> -Mike-


0
AliR1 (391)
2/21/2005 6:27:52 PM
Debaser wrote:
> Thank you to all who helped with the "Select Directory" dialog. I'm
> now faced with a new problem that I should have forseen. How do I get
> all of the file names in this directory (where the path is represented
> as a CString)?
> 

If you are looking to scan a folder for all the files, you need to use
the FindFirstFile/FindNextFile API calls.

-- 
Jonathan Arnold
inSORS
0
2/21/2005 6:31:14 PM
Thank you both. That should solve my problems!

-Mike-
0
guest (34)
2/21/2005 7:32:29 PM
FindFirstFile/FindNextFile/CloseFind. Or the MFC equivalent, the CFindFile (or is it
CFileFind? Check docs) class.

Note that enumerating file names while building a tree is a losing idea. I discovered this
the hard way the first time I did it. Instead, handle the TVN_EXPANDING notification and
at that point, and that point only, expand the file list for the directory being expanded.

The nice thing is that you can iterate upwards using GetParent to pick up the components
of the filename. So what I did was get the string of the expanding node. Then I see if it
has a parent, and if so, I recur with the string "\thisnode", and prepend the parent node
to the string, etc., until I get to the root. By passing in a CString &, when I return,
the entire path has been constructed. Then I enumerate all the files in the directory,
adding them...and the folders as well...and add them as subnodes to the expanding node.

This is known as "lazy evaluation", and works very well in this context. 

If you don't do lazy evaluation, you can spend several minutes trying to load the box.
				joe
On Mon, 21 Feb 2005 13:21:08 -0500, Debaser <guest@unknown.com> wrote:

>Thank you to all who helped with the "Select Directory" dialog. I'm
>now faced with a new problem that I should have forseen. How do I get
>all of the file names in this directory (where the path is represented
>as a CString)?
>
>Sorry if this isn't an MFC question.
>
>Thanks,
>-Mike-

Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
0
newcomer (15972)
2/22/2005 6:15:01 AM
Reply:

Similar Artilces:

Precompiled headers and directories/folders in filesystem...
i basically understand what pchs are, but i dont know exactly how their includition interact with the filesystem, and therefore have ... switch (MyProblems) { case P1: "Unexpected end of file while looking for precompiled header directive..." break; case P2: "d:\microsoft visual studio\vc98\include\crtdbg.h(536): error C2833: 'operator DEBUG_NEW' is not a recognized operator or type..." (recompiling at once helps) break; case P3: "file not found: stdafx.h" break; } _________________________________________...

oppening a directory
When I open a directory to check its contents Windows displays the search screen. I think it´s happening because the first option displayed on the shortcut menu is "Search". What should I do so that it displays the contents of the directory. -------- Original-Nachricht -------- > When I open a directory to check its contents Windows displays the search > screen. > I think it´s happening because the first option displayed on the shortcut > menu is "Search". > What should I do so that it displays the contents of the directory. ...

Parsing Question
I've done parsing where you have one delimiter such as a comma or space. What if you have more than one? Example data: sStr(0) = "3/9" sStr(1) = "3/11 3/15-" sStr(2) = "3/8+ 3/12" sStr(3) = "3/9 3/15" sStr(4) = "3/8- 3/10+ 3/15" The strings above are Month/Day with some having an additional - or + character next to it. These dates are extracted from Excel cells as strings. I need to break those strings down into individual dates. So for sStr(4), I need to parse out "3/8", "3/10" and "3/15&...

how to parse <?xml version="1.0" encoding="UTF-8"?> with xpath? is it possible?
how to parse <?xml version="1.0" encoding="UTF-8"?> with xpath? is it possible? "Daniel" <softwareengineer98037@yahoo.com> wrote in message news:%23g11DbDOGHA.2176@TK2MSFTNGP10.phx.gbl... > how to parse <?xml version="1.0" encoding="UTF-8"?> with xpath? is it > possible? No -- the xml declaration is not represented in the XML Infoset. Cheers, Dimitre Novatchev ...

Directory Replication Problem
I am not getting any error at the time of directory replication but some id's r not getting updated i am not getting any solution to resolve this problem Hey, Goto your Event Viewer and check for the eoors that your getting and tell us the event ID's cheers Ruwan "Pradip Prajapati" <pradipmay@hotmail.com> wrote in message news:2439501c45f3a$225f4f70$a501280a@phx.gbl... > > > I am not getting any error at the time of directory > replication but some id's r not getting updated > > i am not getting any solution to resolve this proble...

Parse Nested Elements to Single DataGrid
I have been losing my mind trying to parse an XML document (with nested child elements, not all of which appear in each parent node) into a DataGrid object. What I want to do is "flatten" the XML document into a text document with a single row for each parent node (that has all of the values from all of the child nodes for that row) The DataView within VS 2005 IDE displays my 15 or so child tables - and knows that some parent rows don't have child rows in every relation - but trying to get all the child tables to go with the correct parent row programmatically is killin...

Summary of multiple workbooks in a directory
Hi again, I have a bundle of workbooks, each one has a summary page. These will all be saved in the same directory eventually. I would like to have a worksheet that presented me all teh summary pages (ordered alphabetically by one of he fields). Excel can trwal a directory for all .xls and extract an area from a worksheet then order on a cell? I am not sure where to start on this and a web search was not much help so far. TIA W Hi as a starting point: http://www.rondebruin.nl/copy3.htm >-----Original Message----- >Hi again, I have a bundle of workbooks, each one has a summar...

Parsing cells
Hi Folks, I have data in cells which is OCR`d from my phone bill, and some of the info is corrupt. Where I should be getting eg. 17 Nov 14:49 for date/time I am getting O17 Nov 14:49 or C17Nov 14:49. The reason is that there are unreadable icon characters to signify day or night. Questions: 1)How do I remove the faulty characters......they are always the first digit in the date if they are there. 2)How can I seperate the date and time into two adjasent colums of cells rather than their current format in one cell. Any and all help greatly appreciated. John Hi John You ca...

Setup new virtual directory in existing Reporting Services deployment
Hi We have RS running on a 2005 cluster. So, the dbs are in the clustered instance and the service runs on each node. We have one application using the service, which is configured to use the default web site, ie, the cluster name, in this case //<cluster_name>/reports I have another application that needs to use reporting services. This app has it's own web server already. Can I use the reporting services already running on the cluster, but setup with new virtual directory on the applications web-server. So, the databases would stay where they are on the cluster, but th...

How to insert an existing macro into "Additional Include Directories"?
I have post this to another group. To avoid cross posting, I give the link to the original post. http://groups.google.com/group/microsoft.public.vsnet.general/browse_thread/thread/bc7ece9c00632947?hl=zh-CN Please give some consideration. Thanks in advance. ...

Messages Awaiting Directory Lookup slow
We ran into a problem today. Normally our Exchange 2000 SP3 server is very quick at sending/receiving emails. However today, messages have been very very slow. Checking the SMTP queues, I see that messages are piling up in the 'Messages Awaiting Directory Lookup' queue. If I reboot the server, alot of the messages appear to start flowing, but then the problem starts up again a few minutes after reboot. External email seems fine, but internally, very slow if at all. I also noticed earlier today that the inetinfo.exe process was using a huge amount of memory (1.2 GB). There...

Parsing CSV
Hi, im using A file with records in my mfc application, i need to read*/write records to the file anybody ahs a clue where should i start? Take a look at CStdiofile and CString::Format() (for output) and CString::Tokenize() (for parsing input). You can use ReadString() and WriteString() to access the file line by line. Tom "fima" <fkpkot@gmail.com> wrote in message news:eXA9vp95FHA.1184@TK2MSFTNGP12.phx.gbl... > Hi, > im using A file with records in my mfc application, i need to read*/write > records to the file anybody ahs a clue where should i start? >...

Parsing
Hello, I have an Excel application where I read a text file.Recently the text file had a change and had three(3) new fields added.This data is now in the last column.I want to parse this data which has a space delimiter into three seperate columns.There are 10 fields and the data is captured in the last column.How do I do this in VBA without the "text to column" manual method. Thanks, Roy Try using the VBA TextToColumns method... In article <1193081380.394989.87940@q5g2000prf.googlegroups.com>, Roy <praish1998@yahoo.com> wrote: > How do I do this in VBA without...

Open and Save Files in Directory
I'd like to be able to select a directory and for each .xls file found in the directory 1) open the .xls file 2) write the name and date saved in another workbook (in this case "workbook report.xls") and 3) save and close the workbook. I have the shell of the loop but I'm missing the pieces where I've written comments. A solution for this would be greatly appreciated! Thanks. Sub OpenAndSaveFiles() Dim wkbk As Workbook Dim StrWkbk As String ' open a form that allows the user to select a directory i.e. C:\temp Workbooks("Workbook Report.xls&qu...

Import CSV file contacts into ACtive Directory
OK.. so I have been fighting to get this working and I am still unable to get the file working. I have read all instructions I can find on CSVDE and cannot get how to fix this. I am trying to import all contacts from our former webmail to Exchange 03. I have the file, but when I go to import it, I get this log Connecting to "(null)" > Logging in as current user using SSPI > Importing directory from file "c:\csvde.txt" > objectClass Attribute not defined > 0 entries modified successfully. > An error has occurred in the program Anyone know how I can fix th...

XML parsing in VB
<rss version="2.0"> <channel> <title>Latest P</title> <link>/P</link> <description>A brief overview of the weather for the week ahead.</description> <language>en-us</language> <item> <title>Tue 1/12 : 2 Stars</title> <link>/P</link> <description> *Rating :: 2 Stars*. SSSS :: 11 ft @ 7 secs. Wind :: 26mph SSE </description> </item> Above is a sample copy of the xml, from which I wish to extract and display items based on the bolded text ( i.e. those which h...

Creating directory on Outlook 2002 Pro Shortcut Bar
I am trying to get my mail organized and was wondering if there is a way to create a directory on the Outlook 2002 Shortcut Bar? Earlier I imported mail from Outlook Express a couple of times and it made a disorganized mess. For reasons unknown, my Outlook Express Mail Program keeps crashing Don't forget to change the (at) in my e-mail address to the correct symbol. Please e-mail me a response Thank Do you mean a new group on the shortcut bar. Right click in an open area of the shortcut bar and select New Group. --� Milly Staples [MVP - Outlook] Post all replies to the group...

Parsing imported csv data
I need to find a way to parse data that I'm importing when the data has a comma "," delimiters. Sometimes the string has a comma in the name (i.e. GenVec, Inc. or RealNetworks, Inc) and sometimes the number amount has commas indicating thousands or millions. I have no control over the format of the imported data since it comes from an external website. I'm using XML functions to import such as: Dim objXML As Object Set objXML = CreateObject("MSXML2.ServerXMLHTTP") Debug.Print "Company Name = " & Split(objXML.responseText, ",&...

log parsing
can someone point me in the right direction for creating/implementing a script for ms exchange that will parse the log files for all incoming and outgoing emails? is it recommended to use the Microsoft LogParser tool for this? thx, jt You really should not be messing with Exchange log files. What are you hoping to achieve? Nue "JTL" <jliautaud@hotmail.com> wrote in message news:u2vVyH2KGHA.3100@tk2msftngp13.phx.gbl... > can someone point me in the right direction for creating/implementing a > script for ms exchange that will parse the log files for all incom...

Active Directory Query
Guys, I have a list of users in a .csv file. The users are listed via firstName, lastName Is there anyway I can use dsquery or any other tools to grab the user's login id after it's compared to the name? Normally for a single name I would do something like dsquery user -name "Nik Test" | dsget user -samid Win2003 sp2 Thanks use for loop in a batch script or u can use Power Shell too (that will give u very good formatting option) for /F "delims=;" %i in (User_List.txt) do dsquery user -name "%i" | dsget user -samid >> C:\Temp.tx...

How to parse message automatically
I want to use a rule to parse the information in emails from a specific email address, convert the content into a MS Word template format, and then email the document as an attachment to an email address that will be one of the "fields" in the received email. Anyone who has had experience with anything like this? Thanks You may need to use VBA, but take a look at www.ornic.com - exlife might do what you need. -- Diane Poremsky [MVP - Outlook] Author, Teach Yourself Outlook 2003 in 24 Hours Coauthor, OneNote 2003 for Windows (Visual QuickStart Guide) Outlook Tips: http://www...

Outlook Syndicated Content (RSS) Directory Error
Hi. I use Outlook 2007 and have started trying to use the Outlook RSS Reader, but it doesn't seem to be working. I have subscribed to one RSS feed and added it directly into Outlook 2007 and the folder is showing that there are 10 new items (it has 10 in brackets), but every time I open the folder I just get the standardised "Outlook Syndicated Content (RSS) Directory" message and a message saying an error has occurred with the scripts on this page - I can't actually see any of the RSS updates as emails. Can anyone help me?! Squeeler wrote: > Hi. I use ...

How to parse out customer email addresses?
I don't see where the email address is available in any of the reports (including crystal report fields) such that I can dump all of the available customer email addresses to a file to build an email distribution list. Any ideas? Thanx! -=RFM=- hitman, If you are the M$ support plan, there is a Customer List with Email address report in CustomerSource. http://tinyurl.com/42qqo -- * "hitman" <hitman@discussions.microsoft.com> wrote in message news:CD42FC6B-A9CD-4F77-A110-DE6AEB41572B@microsoft.com... I don't see where the email address is available in any ...

XMLElement and Type Parse.
Hello, I am writing/reading data to/from a XML file using XMLDocument and XMLElement. I am confused on the data conversions. For example: This is how I create an XElement: XElement product = new XElement("Message", new XElement("Id", id.ToString()), new XElement("Description", product.Description), new XElement("Active", product.Active.ToString()) ); And this is how I read it: Product product = _products.Root.Elements("Product").Select(p => new Product { Id = XmlConvert.ToI...

Company Directory in Business Portal
I deleted on accident the business card web part from the Company Directory page on Business Portal 3.0. How do I get it back? Thanks, Brent ...