k_k
k_k

Reputation: 83

Listing Directory Entries with Qt on Remote Windows Server

I am on a Windows Server which is in the same network as the Server with the computer name service. I got this simple code which tries to list the content

QFileInfoList fiList = QDir("\\service\\Documents").entryInfoList(QDir::Files);
qDebug() << "sizeof filist: " << fiList.size();
for (const QFileInfo& fi : fiList)
{
   qDebug() << fi.absoluteFilePath();
}

The output is the following:

sizeof filist:  0

I make sure that the folder is shared on the network by checking the properties and also using the windows explorer. I can access the folder via Windows Explorer.

Is the functionality I am trying to achieve not possible with QDir?

Upvotes: 0

Views: 138

Answers (1)

k_k
k_k

Reputation: 83

It turns out there are 2 backslashes more needed because \ needs to be escaped.

So the right code would be:

QFileInfoList fiList = QDir("\\\\service\\Documents").entryInfoList(QDir::Files);
qDebug() << "sizeof filist: " << fiList.size();
for (const QFileInfo& fi : fiList)
{
   qDebug() << fi.absoluteFilePath();
}

Upvotes: 1

Related Questions