Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4342108
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T11:34:27+00:00 2026-05-21T11:34:27+00:00

I am using the directory class to get this information but unable to assign

  • 0

I am using the directory class to get this information but unable to assign this data to a data member of my own class. i am doing an oop project. Furthermore,I want to use the concept of Dynamism(containment).I have created two class, mydirectory and myfiles as under:

class files
{
    string fname[25];
public:
    files()
    {
      fname=NULL;
    }

};

class directory
{ private:
    directory *d;
    string *dname[25];   //* to show there may be a subdirectory,there may be not.
    files *ff[25];       // data member string *fname[25];
int numd,numf;
public:
    directory()
    {
    numd=0;numf=0;
    }

Now when if I want to use the statment:

 Directory::GetDirectories("D:\\"); 

how can I assign the directory names to “dname” of directory class.

I dont want to include a third party software.

also i need help on the topic: how can a file (doc file/pdf/txt/pwt etc) can be opened from c++ code outside the console? I am very worried. please help me. thanks in advance.

I am new to c++ so please forgive if there are any errors in pointer handling, as I am doing this containment for the first time. I also need some reading stuff.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T11:34:28+00:00Added an answer on May 21, 2026 at 11:34 am

    Finally I completed the short project.To get the list of files and sub directories, I made use of .NET Framework namespace "System".It has got classes like “FileInfo” and “DirectoryInfo“(both belong to System::IO) which do the above required task.But here,all the string related stuff is of System::String , not of std::string.To convert System::String to std::string, I used the following code(I got this conversion’s code from a forum and it worked fine without any error):

    string Str2str(String ^a)
    {
    array<Byte> ^chars = System::Text::Encoding::ASCII->GetBytes(a);
    pin_ptr<Byte> charsPointer = &(chars[0]);
    char *nativeCharsPointer = reinterpret_cast<char *>(static_cast<unsigned char *>(charsPointer));
    string native(nativeCharsPointer, chars->Length);
    return native;
    }
    

    Here is a short code for getting list of sub directories from a drive(D: drive is going to be searched):

     #include<iostream>
            #using<mscorlib.dll>
            using namespace strd;        
            using namespace System;
            using namespace System::IO;
    
    
    int main()
        {int count=50;
    string name[count];//to hold directories names
    string b;
    int s=0;
    DirectoryInfo^ di = gcnew DirectoryInfo("d:\\");
    if(di->Exists)
    {array<DirectoryInfo^>^diArr = di->GetDirectories();
    Collections::IEnumerator^ myEnum = diArr->GetEnumerator();
    while ( myEnum->MoveNext() )
    {DirectoryInfo^ dri = safe_cast<DirectoryInfo^>(myEnum->Current);
    
    
          String ^a=(dri->Name->ToString());
          int n=b.size();
          b=Str2str(a); `// code given in the starting`
          if (s<count)
          {name[s]=b;
          s++;}
    
    }
    

    This involves Managed C++ knowledge. Visit these:

    .NET Programming Guide

    C++: The Most Powerful Language for .NET Framework Programming

    I compiled this on Visual Studio 2008. I will be very grateful if you appriciate my effort.Further suggestions are most welcomed.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to change a site's home directory using powershell. This is what I
I am trying to get a list of subdirectories in a given directory using
I'm using SQL Server ADSI to import data from Active Directory and using the
Apparently I can't move files on different volumes using Directory.Move. I have read that
How exactly can I create a new directory using Emacs? What commands do I
I am attempting to compare files in a directory using SML. Using the TextIO
How can I iterate over each file in a directory using a for loop?
I'm looking at moving my application from using active directory membership provider to using
I am trying to rename all the files present in a Windows directory using
As I understand it, the command to ignore the content of a directory using

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.