Skip to content

Чтение файлов в папке VC++

by admin on November 8th, 2011

Чтение файлов в папке VC++

// enum_files.cpp
// compile with: /clr
using namespace System;
using namespace System::IO;

int main()
{
   String^ folder = "C:\\";
   array^ dir = Directory::GetDirectories( folder );
   Console::WriteLine("--== Directories inside '{0}' ==--", folder);
   for (int i=0; iLength; i++)
      Console::WriteLine(dir[i]);

   array^ file = Directory::GetFiles( folder );
   Console::WriteLine("--== Files inside '{0}' ==--", folder);
   for (int i=0; iLength; i++)
      Console::WriteLine(file[i]);

   return 0;
}

http://msdn.microsoft.com/en-us/library/t49t9ds1.aspx

String^ folder = "C:\\";
array^ dir = Directory::GetDirectories( folder );
for (int i=0; iLength; i++){
         this->listBox3->Items->Add(dir[i]);
}
array^ file = Directory::GetFiles( folder );
for (int i=0; iLength; i++){
	  this->listBox3->Items->Add(file[i]);
}

Comments are closed.