Fastest way to check a file exists
-
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
-
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
-
what's your code please ? these functions are not so long for me...
TOXCCT >>> GEII power
[toxcct][VisualCalc]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. -
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. -
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]