?
Solved

changing read-only status of files copied from a CD

Posted on 2003-03-06
4
Medium Priority
?
211 Views
Last Modified: 2013-11-20
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?

0
Comment
Question by:klingej
  • 2
  • 2
4 Comments
 
LVL 86

Expert Comment

by:jkr
ID: 8081431
>>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);
0
 

Author Comment

by:klingej
ID: 8082440
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?

0
 
LVL 86

Accepted Solution

by:
jkr earned 200 total points
ID: 8082477
>>Any ideas?

Sorry, my fault - should be

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


0
 

Author Comment

by:klingej
ID: 8082577
Aahh..  makes sense.

Thanks!
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
The Relationships Diagram is a good way to get an overall view of what a database is keeping track of. It is also where relationships are defined. A relationship specifies how two tables connect to each other. As you build tables in Microsoft Ac…

615 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question