Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. File download help

File download help

Scheduled Pinned Locked Moved C / C++ / MFC
c++sysadmintoolshelpquestion
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Sunil P V
    wrote on last edited by
    #1

    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

    D 1 Reply Last reply
    0
    • S Sunil P V

      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

      D Offline
      D Offline
      David Crow
      wrote on last edited by
      #2

      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

      S 1 Reply Last reply
      0
      • D David Crow

        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

        S Offline
        S Offline
        Sunil P V
        wrote on last edited by
        #3

        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

        _ D 2 Replies Last reply
        0
        • S Sunil P V

          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

          _ Offline
          _ Offline
          _Flaviu
          wrote on last edited by
          #4

          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 ...

          1 Reply Last reply
          0
          • S Sunil P V

            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

            D Offline
            D Offline
            David Crow
            wrote on last edited by
            #5

            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

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups