Use QDir::toNativeSeparators() which replace slashes with backslashes

Best Regards

Am 15.02.2012 um 12:58 schrieb Graham Labdon <graham.lab...@avalonsciences.com>:

> Hi
> I am trying to use the windows FindFirstFile function.
> In the code below the call to FindFirstFile always fails with the error 
> ‘ERROR_INVALID_NAME’
> The file that I set in searchPath does exist.
> Does anyone know the correct way to do this?
>  
> Thanks
>  
> #ifdef Q_OS_WIN
>   WIN32_FIND_DATA FindFileData;
>   HANDLE hFind;
>   QString searchPath = "C:/jobs/daryll/Rcd/f_000001.rcd";
>   WCHAR p[100];
>   int x = searchPath.toWCharArray(p);
>   hFind = FindFirstFile(p, &FindFileData);
>   if (hFind == INVALID_HANDLE_VALUE)
>   {
>         int error;
>         error = GetLastError();
>   }
>   else
>   {
> #ifdef UNICODE
>       qDebug() << QString::fromUtf16((ushort*)FindFileData.cFileName);
> #else
>   qDebug() << QString::fromLocal8Bit(FindFileData.cFileName);
> #endif
>   }
> #endif
>  
>  
>  
> Graham Labdon
>  
> Senior Software Engineer
> Avalon Sciences Limited
> Tel:     +44 (0) 1458 271035
> www.avalonsciences.com
> Company no. 2147892
> Registered in England & Wales
> Registered office: Avalon House Somerton TA11 6SB
>  
> _______________________________________________
> Interest mailing list
> Interest@qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest
_______________________________________________
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest

Reply via email to