Question from a newcomer to QT: when I supply the exists() method of a QFileInfo object with a shared-drive file path, it always returns false, even with me escaping every backslash with another backslash (i.e. \\10.1.2.34.56\dir1). And yes, the directory does exist :) Could there be some other issue at work here, such as a lack of permission for the directory in question? Thanks in advance for any light you might shed on this issue...

有帮助吗?

解决方案 2

As it turns out, my issue had everything to do with permissions and nothing to do with escaping backslashes.

The application I inherited actually has two components: i) the window that provides the GUI interface for the app and (ii) the Window service that does the actual work. The window was able to "see" the shared drive because the Windows userid for which it was running had permission for that drive, whereas the Windows service running as the local system could not. Once I used the Services window to change the service to run under a userid with permission for that drive, then it ran just fine. Thanks for your response...

其他提示

It seems it works correctly on XP (with Qt 4.7.3) either with doubled backslashes or single slashes ('//ip/share/filepath').

Try getting the file url through QFileDialog::getOpenFileName. As it uses a native dialog, it should ask for your login/password if needed.
If QFileInfo can then find that the file exists, you could try using the native API (Windows Networking) to connect or allow access programmatically to the network share.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top