Unable to check file existence if special character exist in path(foloded)



  • unable to check file existence if special character exist in path(foloded)

    " C:\Users\JAVA\Music\Mikaq#$% "

    if i check existence of file at this path i am unable to check it.

    @
    QString coverPath= (QString::fromStdString(album_name.toCString())+".png");
    coverPath=coverPath.remove(QRegExp("\s+$"));
    TagBuilder.storeCoverArt((iterator.fileInfo().absolutePath()+"/"+ coverPath),iterator.fileInfo().absoluteFilePath());
    obj_track.cover_path = iterator.fileInfo().absolutePath()+"/"+coverPath;
    if(!QFile::exists(obj_track.cover_path))
    {
    obj_track.cover_path=QString::fromStdString((iterator.fileInfo().absolutePath()+"/folder.jpg").toStdString());
    if(!QFile::exists(obj_track.cover_path))
    {
    obj_track.cover_path=QString::fromStdString((iterator.fileInfo().absolutePath()+"/folder.png").toStdString());
    if(!QFile::exists(obj_track.cover_path))
    {
    obj_track.cover_path = "qrc:///resources/images/no-artwork.png" ;
    }
    }
    }@


  • Moderators

    Please explain how you are "unable to check" it. What error do you get?

    Also, please provide a simpler version of your code, to make it easier to see the error. The code you posted has too many conversions, that are not related to the error.



  • check this:
    use "double back slash : \" and test it (if not windows , test double slash ://)



  • hello i under stand the problem but dont have result .
    problem is at qml sile image source is not taking special character.
    can you help .

    problem code:

    @ Image {
    id: artwork
    height: 100
    width: 100
    source: coverart //here is the path with special character like(C:/Users/Administrator.VIVEK-PC/Music/Vicky Donor~!@#$%^&()/Vicky Donor.png)
    smooth: true
    z: 9
    anchors.horizontalCenter: parent.horizontalCenter
    anchors.top: parent.top
    anchors.topMargin: 8
    } @


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.