Link to home
Start Free TrialLog in
Avatar of klingej
klingej

asked on

changing read-only status of files copied from a CD

I have a program that is going to be using files that are going to be copied off CD.  I need to be able to read/write to these files.  Is there a way in MFC/Win32 to take off the "read-only" status of the files that are copied from the CD, so I can easily open them in CFile::modeReadWrite mode?

Avatar of jkr
jkr
Flag of Germany image

>>Is there a way in MFC/Win32 to take off the "read-only" status

// get file attributes
DWORD dwAttr = GetFileAttributes ( pszFileName);

// remove the readonly flag
dwAttr |= ~FILE_ATTRIBUTE_READONLY;

// set attributes
SetFileAttributes ( pszFileName, dwAttr);
Avatar of klingej
klingej

ASKER

I tried this code exactly, but it didn't work..  it ended up setting all the attributes because after the 2nd line, dwAttr was 0xffffffff (whereas, before, it was 0x00000021).  Any ideas?

ASKER CERTIFIED SOLUTION
Avatar of jkr
jkr
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of klingej

ASKER

Aahh..  makes sense.

Thanks!