File download help
-
Hi, I am developing a file download utility using MFC. The application downloads a simple file over the internet. During download, is there a way to detect if the network connectivity is lost? Because the CHttpFile->Read function doesn't exit if the connection isn't lost.
Sunil
-
Hi, I am developing a file download utility using MFC. The application downloads a simple file over the internet. During download, is there a way to detect if the network connectivity is lost? Because the CHttpFile->Read function doesn't exit if the connection isn't lost.
Sunil
sunilkpv wrote:
Because the CHttpFile->Read function doesn't exit if the connection isn't lost.
Are you saying that it should exit if the connection is not lost?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
-
sunilkpv wrote:
Because the CHttpFile->Read function doesn't exit if the connection isn't lost.
Are you saying that it should exit if the connection is not lost?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
Sorry. That was a typo. What you said is right. I found a solution for this by setting a timeout using the CInternetSession class. However I have ended up with another similar problem. I am reading a file over the network drive using CFIle class. Now if the network drive access is lost (due to any reason) can we get to know this. The read() function continues without breaking. How can this be solved?? Please help...
Sunil
-
Sorry. That was a typo. What you said is right. I found a solution for this by setting a timeout using the CInternetSession class. However I have ended up with another similar problem. I am reading a file over the network drive using CFIle class. Now if the network drive access is lost (due to any reason) can we get to know this. The read() function continues without breaking. How can this be solved?? Please help...
Sunil
I give some code :
BOOL CYourDoc::DownloadFile(CString sAddress, CString& sResult)
{
CString sTemp;
BOOL bRet = FALSE;
CInternetSession ISession;
CInternetFile* pIFile = NULL;
CMainFrame* pFrame = (CMainFrame*)AfxGetMainWnd();try { pIFile = (CInternetFile\*)ISession.OpenURL(sAddress); while(pIFile->ReadString(sTemp))sResult += sTemp; bRet = TRUE; } catch(CException\* pException) { pException->GetErrorMessage(sTemp.GetBuffer(255),255); sTemp.ReleaseBuffer(); pException->Delete(); pFrame->SetMessageText(sTemp); } if(pIFile) { pIFile->Close(); delete pIFile; } ISession.Close(); return bRet;
}
I this code, when something happened, throw an exception, there you can do whatever you want ... I hope this help you ...
-
Sorry. That was a typo. What you said is right. I found a solution for this by setting a timeout using the CInternetSession class. However I have ended up with another similar problem. I am reading a file over the network drive using CFIle class. Now if the network drive access is lost (due to any reason) can we get to know this. The read() function continues without breaking. How can this be solved?? Please help...
Sunil
sunilkpv wrote:
The read() function continues without breaking.
What is it continuing doing? Reading what? What does your read loop look like?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous