?
Solved

changing read-only status of files copied from a CD

Posted on 2003-03-06
4
Medium Priority
?
200 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses
Course of the Month10 days, 1 hour left to enroll

762 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