Click here to Skip to main content
14,664,816 members
Home » Discussions » C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: save file error! Pin
Richard MacCutchan31-Jan-10 6:19
mveRichard MacCutchan31-Jan-10 6:19 
GeneralRe: save file error! Pin
enhzflep31-Jan-10 6:40
Memberenhzflep31-Jan-10 6:40 
GeneralRe: save file error! Pin
Richard MacCutchan31-Jan-10 7:44
mveRichard MacCutchan31-Jan-10 7:44 
Questionuser defined drag drop control in vc++ Pin
Prajakta Apte 31-Jan-10 1:44
MemberPrajakta Apte 31-Jan-10 1:44 
Questionsave file error! Pin
wbgxx31-Jan-10 1:25
Memberwbgxx31-Jan-10 1:25 
AnswerRe: save file error! Pin
Cedric Moonen31-Jan-10 1:43
MemberCedric Moonen31-Jan-10 1:43 
AnswerRe: save file error! Pin
Richard MacCutchan31-Jan-10 2:38
mveRichard MacCutchan31-Jan-10 2:38 
QuestionProblem with CFile:Open and Sharing Violation [modified] Pin
hollesser00130-Jan-10 23:20
Memberhollesser00130-Jan-10 23:20 
Hello!

In my MFC programm on Visual C++ 2008 i have the following problem with opening a file for reading:

-------------------------------------------
1) First step i do is to unzip a existing file (sSourceFile) containing my data with CZipArchive
Here to simplify matters without exception handling:

CZipArchive ZipArchive;
ZipArchive.Open(sSourceFile, CZipArchive::zipOpenReadOnly);

for (int i = 0; i < ZipArchive.GetCount(); i++)
{
ZipArchive.SetPassword(key);
ZipArchive.ExtractFile(i, GetProgramPath()); // GetProgramPath() is a own method which returns the current path
}

ZipArchive.Close();

-------------------------------------------
2) After that i rename the unzipped file:

DeleteFile(sTargetFile);
CFile::Rename( sSourceFile, sTargetFile ); // both, sSourceFile and sTargetFile, with full qualified path

So far it works without problems. The sTargetFile exists (reviewed by debugging).

-------------------------------------------
3) Now i want to open the renamed file for reading

CFile file;
file.Open(sTargetFile, CFile::modeRead);

-------------------------------------------

After that on some machines (with Windows 7) i get an CFileException::sharingViolation exception.
But on the most machines it works without an exception.

What is the matter for this exception?
Does the CFile::Rename still block the file?
How i can wait until the file is definitively closed?

Please help me!

modified on Sunday, January 31, 2010 5:51 AM

AnswerRe: Problem with CFile:Open and Sharing Violation Pin
Garth J Lancaster31-Jan-10 0:09
professionalGarth J Lancaster31-Jan-10 0:09 
QuestionRe: Problem with CFile:Open and Sharing Violation Pin
hollesser00131-Jan-10 3:00
Memberhollesser00131-Jan-10 3:00 
Questiondetect enter key on edit control Pin
Sauce!30-Jan-10 22:14
MemberSauce!30-Jan-10 22:14 
AnswerRe: detect enter key on edit control Pin
Alain Rist30-Jan-10 23:02
MemberAlain Rist30-Jan-10 23:02 
GeneralRe: detect enter key on edit control Pin
Sauce!30-Jan-10 23:21
MemberSauce!30-Jan-10 23:21 
GeneralRe: detect enter key on edit control Pin
Alain Rist30-Jan-10 23:22
MemberAlain Rist30-Jan-10 23:22 
AnswerRe: detect enter key on edit control Pin
Richard MacCutchan31-Jan-10 1:25
mveRichard MacCutchan31-Jan-10 1:25 
GeneralRe: detect enter key on edit control Pin
Sauce!31-Jan-10 2:12
MemberSauce!31-Jan-10 2:12 
QuestionSet background color of Menu. Pin
Le@rner29-Jan-10 20:17
MemberLe@rner29-Jan-10 20:17 
AnswerRe: Set background color of Menu. Pin
LunaticFringe30-Jan-10 1:47
MemberLunaticFringe30-Jan-10 1:47 
Questionchar* returns garbage value Pin
Anu_Bala29-Jan-10 19:10
MemberAnu_Bala29-Jan-10 19:10 
AnswerRe: char* returns garbage value Pin
Richard MacCutchan29-Jan-10 22:23
mveRichard MacCutchan29-Jan-10 22:23 
AnswerRe: char* returns garbage value Pin
«_Superman_»30-Jan-10 20:28
professional«_Superman_»30-Jan-10 20:28 
Questionextracting data from .TXT file Pin
benjamin yap29-Jan-10 17:20
Memberbenjamin yap29-Jan-10 17:20 
AnswerRe: extracting data from .TXT file Pin
Richard MacCutchan29-Jan-10 22:19
mveRichard MacCutchan29-Jan-10 22:19 
AnswerRe: extracting data from .TXT file Pin
enhzflep30-Jan-10 7:02
Memberenhzflep30-Jan-10 7:02 
AnswerRe: extracting data from .TXT file Pin
Moak30-Jan-10 13:11
MemberMoak30-Jan-10 13:11 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.