hy guyz,
I want to create a windows 'shell'(CLI based) in C++ (like Windows cmd) which has ability to Create folder or file, copy and paste and delete folders or files...
So plz help me and tell me the which libraries will use because i have no idea about this.
If any person found the beginner-level tutorial then tell me....

Check out something like this:
It is a simple framework where you can add your commands.
Keep in mind you will need to fix it to handle commands with parameters.

// DW_393014.cpp : main project file.

#include "stdafx.h"

using namespace System;
using namespace System::Collections::Generic;
using namespace System::IO;
using namespace System::Linq;

public ref class CCommands
{
public:
   static void ShowDir(void)
   {
      Enumerable::ToList<String^>(
         Directory::GetFiles(Directory::GetCurrentDirectory()))
         ->ForEach(gcnew Action<String^>(Console::WriteLine));
   }

   static String^ NowTime()
   {
      DateTime^ dt = DateTime::Now;
      return String::Format("{0:G}:{1:G}:{2:G}",
         dt->Hour.ToString()->PadLeft(2, '0'),
         dt->Minute.ToString()->PadLeft(2, '0'),
         dt->Second.ToString()->PadLeft(2, '0')
         );
   }

   static void DoHelp()
   {
      Console::WriteLine("Commands are: " +
         String::Join(", ",
            Enumerable::ToList<String^>(
               Enumerable::Select(GetCommands(),
                  gcnew Func<KeyValuePair<String^, Action^>,String^>(GetKey)))
                     ->ToArray()) + ", quit, exit");
   }

   static List<KeyValuePair<String^, Action^>>^ GetCommands()
   {
      List<KeyValuePair<String^, Action^>>^ lst_kvp_s2aCommands = gcnew List<KeyValuePair<String^, Action^>>();
      lst_kvp_s2aCommands->Add(KeyValuePair<String^, Action^>("spy", gcnew Action(CCommands::ShowDir)));
      lst_kvp_s2aCommands->Add(KeyValuePair<String^, Action^>("wipe", gcnew Action(Console::Clear)));
      lst_kvp_s2aCommands->Add(KeyValuePair<String^, Action^>("help", gcnew Action(CCommands::DoHelp)));
      return lst_kvp_s2aCommands;
   }

private:
   static String^ GetKey(KeyValuePair<String^, Action^> kvp_s2a)
   {
      return kvp_s2a.Key;
   }
};

int main(array<System::String ^> ^args)
{
   Console::WriteLine(L"Welcome to CLI Shell (v1.0)\n");
   String^ strCommand = "";

   List<KeyValuePair<String^, Action^>>^ lst_kvp_s2aCommands = CCommands::GetCommands();

   while(!strCommand->Equals("exit") && !strCommand->Equals("quit"))
   {
      Console::Write("{0}>: ", CCommands::NowTime());
      strCommand = Console::ReadLine()->ToLower();

      for each(KeyValuePair<String^, Action^> kvp_s2a in lst_kvp_s2aCommands)
      {
         if(!kvp_s2a.Key->Equals(strCommand))
         {
            continue;
         }

         kvp_s2a.Value();
      }
   }

   return 0;
}

i compiled your code in Dev-cpp, it displays no. of errors...
And tell me that where your code will successfully compiled?

You have not attach #include "stdafx.h" file, so i think due to this it not compiled successfully...

Line three (3) is the include of stdafx.h
I created this with VS 2010 and compiled it with Warning Level 4.

Edited 5 Years Ago by thines01: n/a

Check out something like this:
It is a simple framework where you can add your commands.
Keep in mind you will need to fix it to handle commands with parameters.

// DW_393014.cpp : main project file.

#include "stdafx.h"

using namespace System;
using namespace System::Collections::Generic;
using namespace System::IO;
using namespace System::Linq;

public ref class CCommands
{
public:
   static void ShowDir(void)
   {
      Enumerable::ToList<String^>(
         Directory::GetFiles(Directory::GetCurrentDirectory()))
         ->ForEach(gcnew Action<String^>(Console::WriteLine));
   }

   static String^ NowTime()
   {
      DateTime^ dt = DateTime::Now;
      return String::Format("{0:G}:{1:G}:{2:G}",
         dt->Hour.ToString()->PadLeft(2, '0'),
         dt->Minute.ToString()->PadLeft(2, '0'),
         dt->Second.ToString()->PadLeft(2, '0')
         );
   }

   static void DoHelp()
   {
      Console::WriteLine("Commands are: " +
         String::Join(", ",
            Enumerable::ToList<String^>(
               Enumerable::Select(GetCommands(),
                  gcnew Func<KeyValuePair<String^, Action^>,String^>(GetKey)))
                     ->ToArray()) + ", quit, exit");
   }

   static List<KeyValuePair<String^, Action^>>^ GetCommands()
   {
      List<KeyValuePair<String^, Action^>>^ lst_kvp_s2aCommands = gcnew List<KeyValuePair<String^, Action^>>();
      lst_kvp_s2aCommands->Add(KeyValuePair<String^, Action^>("spy", gcnew Action(CCommands::ShowDir)));
      lst_kvp_s2aCommands->Add(KeyValuePair<String^, Action^>("wipe", gcnew Action(Console::Clear)));
      lst_kvp_s2aCommands->Add(KeyValuePair<String^, Action^>("help", gcnew Action(CCommands::DoHelp)));
      return lst_kvp_s2aCommands;
   }

private:
   static String^ GetKey(KeyValuePair<String^, Action^> kvp_s2a)
   {
      return kvp_s2a.Key;
   }
};

int main(array<System::String ^> ^args)
{
   Console::WriteLine(L"Welcome to CLI Shell (v1.0)\n");
   String^ strCommand = "";

   List<KeyValuePair<String^, Action^>>^ lst_kvp_s2aCommands = CCommands::GetCommands();

   while(!strCommand->Equals("exit") && !strCommand->Equals("quit"))
   {
      Console::Write("{0}>: ", CCommands::NowTime());
      strCommand = Console::ReadLine()->ToLower();

      for each(KeyValuePair<String^, Action^> kvp_s2a in lst_kvp_s2aCommands)
      {
         if(!kvp_s2a.Key->Equals(strCommand))
         {
            continue;
         }

         kvp_s2a.Value();
      }
   }

   return 0;
}

when i compile ur code then these following errors display:
ClCompile:
All outputs are up-to-date.
dfa.cpp
c:\documents and settings\bsef09a039\desktop\dfa\dfa\dfa.cpp(7): error C2871: 'System' : a namespace with this name does not exist
c:\documents and settings\bsef09a039\desktop\dfa\dfa\dfa.cpp(8): error C2653: 'System' : is not a class or namespace name
c:\documents and settings\bsef09a039\desktop\dfa\dfa\dfa.cpp(8): error C2871: 'Generic' : a namespace with this name does not exist
c:\documents and settings\bsef09a039\desktop\dfa\dfa\dfa.cpp(9): error C2653: 'System' : is not a class or namespace name
c:\documents and settings\bsef09a039\desktop\dfa\dfa\dfa.cpp(9): error C2871: 'IO' : a namespace with this name does not exist
c:\documents and settings\bsef09a039\desktop\dfa\dfa\dfa.cpp(10): error C2653: 'System' : is not a class or namespace name
c:\documents and settings\bsef09a039\desktop\dfa\dfa\dfa.cpp(10): error C2871: 'Linq' : a namespace with this name does not exist
c:\documents and settings\bsef09a039\desktop\dfa\dfa\dfa.cpp(12): error C2059: syntax error : 'public'
c:\documents and settings\bsef09a039\desktop\dfa\dfa\dfa.cpp(13): error C2143: syntax error : missing ';' before '{'
c:\documents and settings\bsef09a039\desktop\dfa\dfa\dfa.cpp(13): error C2447: '{' : missing function header (old-style formal list?)
c:\documents and settings\bsef09a039\desktop\dfa\dfa\dfa.cpp(58): error C2065: 'array' : undeclared identifier
c:\documents and settings\bsef09a039\desktop\dfa\dfa\dfa.cpp(58): error C2653: 'System' : is not a class or namespace name
c:\documents and settings\bsef09a039\desktop\dfa\dfa\dfa.cpp(58): error C2065: 'String' : undeclared identifier
c:\documents and settings\bsef09a039\desktop\dfa\dfa\dfa.cpp(58): error C2059: syntax error : '>'
c:\documents and settings\bsef09a039\desktop\dfa\dfa\dfa.cpp(59): error C2143: syntax error : missing ';' before '{'
c:\documents and settings\bsef09a039\desktop\dfa\dfa\dfa.cpp(59): error C2447: '{' : missing function header (old-style formal list?)

This code also requires the Dot Net 3.5 framework (C++/CLI as you requested).

The stdafx reference was created by Visual Studio.
The .h file contains only one line

#pragma once

The multitude of errors you're getting suggest that you do not have your environment set up properly.

Start with the first error:
'System' : a namespace with this name does not exist
The System namespace is an integral part of the Dot Net framework.
If it can't be found, either you are not building this as a dot net app or your environment is messed up.

Edited 5 Years Ago by thines01: n/a

Did you fix it?
If not, you should start a new Console App project WITH Pre-compiled header.
Once created, paste this code into the main module.

Correction on my statement:
It requires at least Dot Net 3.5 (4+ if you're using VS 2010)

i am not aware about visual studio compiler..
Please can anyone tell me the code that can run on Dev-cpp...

This article has been dead for over six months. Start a new discussion instead.