Hi,

I'm trying to retrieve the size of a symlink/shortcut (.lnk in Windows) using QFileInfo::size(), but I always end up getting the size of the target of the shortcut.

Assume I have a file 'C:\Temp\testfile.txt' which is of size 653 bytes. Also, I have a shortcut 'testfile.txt.lnk' pointing to the text file. According to Windows, the size of the shortcut (.lnk) is 851 bytes in my case. How shall I do to find this size (851 bytes) with Qt using the path of the shortcut?

Like I said, I thought QFileInfo::size() would to that, but the following example shows that this is not the case (at least not for me):

Qt Code:
  1. QFileInfo info1("C:\\Temp\\testfile.txt.lnk");
  2. qDebug() << info1.isSymLink();
  3. qDebug() << info1.absoluteFilePath();
  4. qDebug() << info1.size() << "!!!!! should be 851!";
  5. qDebug() << info1.symLinkTarget();
  6. qDebug() << "-----------------";
  7. QFileInfo info2 = QFileInfo(info1.symLinkTarget());
  8. qDebug() << info2.isSymLink();
  9. qDebug() << info2.absoluteFilePath();
  10. qDebug() << info2.size();
To copy to clipboard, switch view to plain text mode 
Output from this test is

true
"C:/Temp/testfile.txt.lnk"
653 "!!!!! should be 851!"
"C:/Temp/testfile.txt"
-----------------
false
"C:/Temp/testfile.txt"
653


I use Qt 5.7.0 in Windows.

Grateful for any help.