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. Managed C++/CLI
  4. Fastest way to check a file exists

Fastest way to check a file exists

Scheduled Pinned Locked Moved Managed C++/CLI
sysadminquestion
5 Posts 2 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.
  • D Offline
    D Offline
    d3m0n
    wrote on last edited by
    #1

    Hi My app stalls at startup because a file in the MRU list is on a network drive that doesn't exist. The exact filename I am trying to add is "\\blah\start.txt". I call CRecentFileList::Add from InitInstance. This Add function goes away for about 10secs before returning failure. So I changed my code so that the Add function is only called if the file actually exists. But every function I tried (PathFileExists, _access, CFile::Open etc etc) always stalls for these 10secs. There must be some function I can use that will check a file exists, which returns immediately... :confused: Any ideas? Thanks d3m0n

    T 1 Reply Last reply
    0
    • D d3m0n

      Hi My app stalls at startup because a file in the MRU list is on a network drive that doesn't exist. The exact filename I am trying to add is "\\blah\start.txt". I call CRecentFileList::Add from InitInstance. This Add function goes away for about 10secs before returning failure. So I changed my code so that the Add function is only called if the file actually exists. But every function I tried (PathFileExists, _access, CFile::Open etc etc) always stalls for these 10secs. There must be some function I can use that will check a file exists, which returns immediately... :confused: Any ideas? Thanks d3m0n

      T Offline
      T Offline
      toxcct
      wrote on last edited by
      #2

      what's your code please ? these functions are not so long for me...


      TOXCCT >>> GEII power
      [toxcct][VisualCalc]

      D 1 Reply Last reply
      0
      • T toxcct

        what's your code please ? these functions are not so long for me...


        TOXCCT >>> GEII power
        [toxcct][VisualCalc]

        D Offline
        D Offline
        d3m0n
        wrote on last edited by
        #3

        for (POSITION pos = listFiles.GetHeadPosition(); pos; ) { CString strFile = listFiles.GetNext(pos); if (_access(strFile, 0) != -1) //takes 10secs if strFile is "\\blah\start.txt" m_pmruFiles->Add(strFile); } This problem only occurs if I am connected to the network. If disconnected, it returns failure immediately.

        T 1 Reply Last reply
        0
        • D d3m0n

          for (POSITION pos = listFiles.GetHeadPosition(); pos; ) { CString strFile = listFiles.GetNext(pos); if (_access(strFile, 0) != -1) //takes 10secs if strFile is "\\blah\start.txt" m_pmruFiles->Add(strFile); } This problem only occurs if I am connected to the network. If disconnected, it returns failure immediately.

          T Offline
          T Offline
          toxcct
          wrote on last edited by
          #4

          this is not a problem a the function but the network access... if you open a windows explorer and reach the networks around you, explorer will take several seconds to show you the first infos...


          TOXCCT >>> GEII power
          [toxcct][VisualCalc]

          D 1 Reply Last reply
          0
          • T toxcct

            this is not a problem a the function but the network access... if you open a windows explorer and reach the networks around you, explorer will take several seconds to show you the first infos...


            TOXCCT >>> GEII power
            [toxcct][VisualCalc]

            D Offline
            D Offline
            d3m0n
            wrote on last edited by
            #5

            toxcct wrote:

            this is not a problem a the function but the network access...

            Yes I have come to the same conclusion. I think it is impossible to solve this problem. Thanks for your help :) Cheers d3m0n

            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