Click here to Skip to main content
15,898,538 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Dilemma with threads and exception :confused: Pin
ta_isr15-May-08 2:45
ta_isr15-May-08 2:45 
GeneralRe: Dilemma with threads and exception :confused: Pin
Cedric Moonen15-May-08 2:47
Cedric Moonen15-May-08 2:47 
AnswerRe: Dilemma with threads and exception :confused: Pin
ta_isr15-May-08 3:14
ta_isr15-May-08 3:14 
QuestionRegFlushKey Pin
Ajay L D14-May-08 20:10
Ajay L D14-May-08 20:10 
AnswerRe: RegFlushKey Pin
ShilpiP14-May-08 21:22
ShilpiP14-May-08 21:22 
GeneralRe: RegFlushKey Pin
Ajay L D15-May-08 1:14
Ajay L D15-May-08 1:14 
QuestionMultiple Monitor Pin
Soumyadipta14-May-08 19:46
Soumyadipta14-May-08 19:46 
Questionunsuccessful move file? Pin
monsieur_jj14-May-08 19:36
monsieur_jj14-May-08 19:36 
Hi all,

I have this downloader code what I do is there is this temp file that where the downloaded file is being stored until completed when completed I want it to be transfered to a new file, I am trying to do this by movefile() however it returns false.
Here is my code maybe anyone of you can see why:

HINTERNET  hConnect = NULL;<br />
	HINTERNET hOpen = NULL;<br />
	HINTERNET	hOpenFile = NULL;<br />
<br />
	HINTERNET hHttpRequest = NULL;<br />
	bool sendReq = FALSE;<br />
	LPTSTR AcceptTypes[2] = {TEXT("application/x-zip-compressed"), NULL}; <br />
<br />
	BOOL bRet = FALSE;<br />
	BOOL bInComplete = FALSE;<br />
	BOOL Exist = FALSE;<br />
	INTERNET_PORT nServerPort =21;<br />
	FILE * pFile = NULL;<br />
	<br />
	DWORD dwPacketSize =5;<br />
<br />
	DWORD dwSize, dwToRead = dwPacketSize * 1024;<br />
	PBYTE  pBuffer  = new BYTE[dwPacketSize * 1024];<br />
<br />
	double dOffsetToSeek =0;<br />
	<br />
	std::string strTmpFileName = "Temp_CaptureFile4210InstallerBuild_4.zip";<br />
	std::string strFileNameAtLocalMachine= "CaptureFile4210InstallerBuild_4.zip\\";<br />
	DeleteFile(strFileNameAtLocalMachine.c_str());<br />
	CString strStaus;<br />
	double dCurrentFileSize;<br />
<br />
	DWORD dwBytesWrrittenToFile =0;<br />
<br />
	if(IfLocalFileExist(strTmpFileName.c_str(), &dCurrentFileSize)) <br />
	{<br />
		dOffsetToSeek				= dCurrentFileSize;<br />
	}<br />
	<br />
	CString strRangeQuest;<br />
<br />
	if(dCurrentFileSize>0){   <br />
	strRangeQuest.Format( _T("%sRange: bytes=%d-\r\n"), szHeaders,static_cast<ULONGLONG>(dCurrentFileSize));<br />
	}<br />
	else        <br />
	strRangeQuest = szHeaders;<br />
<br />
	dwBytesWrrittenToFile = dOffsetToSeek;<br />
<br />
	 if  ( !(pFile = fopen (strTmpFileName.c_str(), "ab" ) ) )<br />
	   {<br />
			CString strMsg;<br />
			strMsg.Format("Error:%d", GetLastError());<br />
			return false;<br />
	   }<br />
	 if(dOffsetToSeek >=0)<br />
	   {<br />
			strStaus.Format("Seeking to local file...");<br />
			int n = fseek(pFile, dOffsetToSeek, SEEK_SET);<br />
	   }<br />
<br />
	//step1<br />
	CInternetSession Session(_T("Test Application"));<br />
	//step2<br />
	CHttpConnection Connection1(Session,_T("http://10.5.1.4/downloads/CaptureFile/CaptureFile4210InstallerBuild_4.zip"));<br />
	//step 3<br />
	BYTE Buffer[4096];<br />
<br />
	CHttpFile File2(Session,_T("http://10.5.1.4/downloads/CaptureFile/CaptureFile4210InstallerBuild_4.zip"));<br />
	CInternetFile::CInfo Info(File2);<br />
	File2.SendRequest(strRangeQuest);<br />
<br />
	for (DWORD dwRead2;dwRead2=File2.Read(Buffer,sizeof(Buffer)); )<br />
	{<br />
		 fwrite(Buffer, sizeof (char), dwRead2 , pFile);	<br />
	}<br />
<br />
		bool moved = MoveFile(strTmpFileName.c_str(), strFileNameAtLocalMachine.c_str());<br />
		DeleteFile(strTmpFileName.c_str());<br />
<br />
	return 0


Thanks,
Jayjay
AnswerIt's still open! Pin
enhzflep15-May-08 6:28
enhzflep15-May-08 6:28 
QuestionModal or Modeless ? Pin
nitin314-May-08 19:21
nitin314-May-08 19:21 
Answer[Message Deleted] Pin
toxcct14-May-08 21:59
toxcct14-May-08 21:59 
GeneralRe: Modal or Modeless ? Pin
nitin314-May-08 22:24
nitin314-May-08 22:24 
QuestionRe: Modal or Modeless ? Pin
CPallini15-May-08 0:15
mveCPallini15-May-08 0:15 
QuestionText Field in MFC Pin
T.RATHA KRISHNAN14-May-08 19:20
T.RATHA KRISHNAN14-May-08 19:20 
AnswerRe: Text Field in MFC Pin
Mukesh Kumar14-May-08 19:59
Mukesh Kumar14-May-08 19:59 
QuestionEEPROM and BlueTooth Pin
IamPoojaa14-May-08 19:10
IamPoojaa14-May-08 19:10 
GeneralRe: EEPROM and BlueTooth Pin
CPallini14-May-08 21:04
mveCPallini14-May-08 21:04 
GeneralRe: EEPROM and BlueTooth Pin
IamPoojaa14-May-08 22:22
IamPoojaa14-May-08 22:22 
QuestionS-ATA and IDE/ATA hard drive Pin
Madan Chauhan14-May-08 18:33
Madan Chauhan14-May-08 18:33 
QuestionSMTP address, IP Address, username and password Pin
shruthi8214-May-08 18:08
shruthi8214-May-08 18:08 
QuestionCOM tutorial site... Pin
RYU^^14-May-08 16:32
RYU^^14-May-08 16:32 
AnswerRe: COM tutorial site... Pin
Rajesh R Subramanian14-May-08 18:27
professionalRajesh R Subramanian14-May-08 18:27 
AnswerRe: COM tutorial site... Pin
Hamid_RT14-May-08 18:28
Hamid_RT14-May-08 18:28 
GeneralRe: COM tutorial site... Pin
RYU^^15-May-08 18:18
RYU^^15-May-08 18:18 
AnswerRe: COM tutorial site... Pin
ShilpiP14-May-08 19:15
ShilpiP14-May-08 19:15 

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.