CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    May 2007
    Posts
    2

    Question CFile::GetStatus takes too much time to check not exist file

    hi,
    I used "static BOOL PASCAL GetStatus( LPCTSTR lpszFileName, CFileStatus& rStatus );" to get file status information in my code, but if the lpszFileName was a network file path(such as "\\192.168.0.125\test\test.txt"), and the "test.txt" file did not exist, it would take a lot of time to wait CFile::GetStatus return.
    Can anything do to cut down the waitng time? Cos my application got lots files to check, and it really take too much time to wait.

    Thanks.
    c chen

  2. #2
    Join Date
    Sep 2005
    Location
    Munich, Germany
    Posts
    24

    Re: CFile::GetStatus takes too much time to check not exist file

    Hello,

    don't know if following works or is even faster.

    Code:
    SHFILEINFO shFileInfo;
    if (0 != ::SHGetFileInfo(lpszFileName, 0, &shFileInfo, sizeof(SHFILEINFO), SHGFI_TYPENAME)) ...

  3. #3
    Join Date
    Aug 2000
    Location
    New York, NY, USA
    Posts
    5,656

    Re: CFile::GetStatus takes too much time to check not exist file

    Quote Originally Posted by c.chen
    Can anything do to cut down the waitng time?
    That CFile::GetStatus() function does a LOT of things.
    If you only need to check existence - try _taccess() with the mode 0.
    Vlad - MS MVP [2007 - 2012] - www.FeinSoftware.com
    Convenience and productivity tools for Microsoft Visual Studio:
    FeinWindows - replacement windows manager for Visual Studio, and more...

  4. #4
    Join Date
    May 2007
    Posts
    2

    Re: CFile::GetStatus takes too much time to check not exist file

    Thanks you two, i tried SHGetFileInfo and _taccess,SHGetFileInfo took about 80s and _taccess just the same as CFile::GetStatus, it took about 27s.
    Any other ideas? I found that CMD tool PING can detect the host's existence quickly. Some way to use that technology?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured