hii
How to open a directory using createfile() ?
Any idea..?

Thanking you.

Use FILE_FLAG_BACKUP_SEMANTICS flag.

This opens the directory, gets the directory size ok, but fails to read the directory. I don't know what can be done with the handle.

#include <windows.h>
#include <iostream>
#include <fstream>
using namespace std;

int main()
{
    HANDLE hFile = CreateFile("C:\\users", GENERIC_READ, FILE_SHARE_READ,
        0, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, 0);
   if( hFile != INVALID_HANDLE_VALUE )
   {
        DWORD dwFileSize = GetFileSize(hFile, 0);
        DWORD dwBytesRead = 0;
        char* buf = new char[dwFileSize];
        ReadFile(hFile, buf, dwFileSize, &dwBytesRead, 0);
        if(dwBytesRead > 0)
        {
            cout << buf << "\0";
        }
        else
        {
            DWORD dwError = GetLastError();
            char tmp[255] = {0};
            FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, 0, dwError, 0,
                tmp, sizeof(tmp), 0);
            cout << tmp << "\n";
        }
        delete[] buf;
        CloseFile(hFile);
   }
}

Actually I wanna copy all the contents of one partition .So how I have to start
the processes

Directory contains so many directories ,files,,Directory contains another directories & files....


I'm really confusing...........
How to do that one....

any idea..
Any body can help me.....

>>copy all the contents of one partition
I don't know what that means. Copy all the files? such as all files/folders on C: to D: ?

Here is the code you need. It will give you the list of all he files and directories. Use the win32 api function CopyFile() to do the actual copying.

>>copy all the contents of one partition
I don't know what that means. Copy all the files? such as all files/folders on C: to D: ?

Here is the code you need. It will give you the list of all he files and directories. Use the win32 api function CopyFile() to do the actual copying.

Yess..
I gotta copy all the files& folder from one volume to another....


anyway thanks for the information....

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