tags:

views:

35

answers:

1

Hi

Can anybody help me in finding out how to verify that _tmkdir succeeded. For example i wish to create a file within another folder. This folder i will create at runtime. So i will give the following command.

sFilePath = sFilePath + _T("\\P-Series Communication Logs");
_tmkdir( sFilePath );

where sFilePath would initially contain a software installation path which will be obtained from registry.

i wish to know if _tmkdir succeeded or not.

Thanks

+1  A: 

You can check the return value of _tmkdir to see if the call succeeded. If it failed, the errno global variable indicates the reason for failure:

int result = _tmkdir(sFilePath);
if (result == 0) {
    // succeeded
}
else {
    // failed
    if (errno == EEXIST) {
        // already exists!
    }
}

For more information, look at the MSDN documentation for _tmkdir here and errno here.

I hope this helps!

ChrisN
Sure this does help. Thanks
ckv