Click here to Skip to main content
15,890,438 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
Hello everyone!

I am facing trouble in doing containership in c++/cli. I have got two classes. One is a directory class with a data member "System::string^ path" and the other class is "file" with the data member "System::String ^ name".

Now the idea is: directory contains a file(composition) and also, a directory may not have any file (dynamism). I am able to do create an inheritance relation, but obviously it doesn't make any sense. So I need a little help on how to create the above described relation between the two classes.

My second problem is: I am doing a project that indexes all the contents of a specified path and then offers different searching methods. One of these methods is, "search by word". I will be limiting it to some 20 predefined words. Now I have to open a file(say a doc file) in the console and then do the string comparision. But I don't have any idea how to open the file in the console and also, how to do the comparison (I mean how a doc file will be treated as a file which is created by using console and how the words will be converted in System::String).

Hope I will get some help from you people:). One request: Kindly don't consider third party softwares as the solutions as I can't use them(BOOST libraries and Dirent.h...)
Posted
Updated 24-Mar-11 5:36am
v3

1. There is not any relationship between your two classes that I can see, although a Directory object may contain File objects.

2. You open a file by one of the file or stream methods. If by a doc file you mean a MSWord document then you will need to refer to the Interop assemblies[^] on MSDN.

Also I don't see the relevance of your references to "the console" in your second question.
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 24-Mar-11 14:34pm    
My 5. I added some info to your Answer.
--SA
In addition to Richard's Answer: there is no such thing as "open file in console". You just open a file, use System::IO::StreamReader as you need just to read it.

If you need content comparison at the level of Microsoft Word document, this is a separate issue. Start from here: http://msdn.microsoft.com/en-us/library/z63ctsh2.aspx[^] or here: http://msdn.microsoft.com/en-us/library/bb726434(v=office.12).aspx[^].

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900