Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
How to send/receive a file from samba shared folder?
Consider me a newbie in Qt network programming. I have a simple UI where I select a file from my local PC and when I click on Send button I would like to send the file over to the samba shared folder.
I know the IP address and the port number I would like to connect to. But I am completely confused about what do I need to send the file. Do I need a Server and Client? Or QTcpSocket would be enough? No idea.
Any pointers to links or examples are appreciated.
The usual way to do that is to mount the Samba share on your machine and use it like any other network drive. Then you can use QFile to copy the file over to it.
Just as a note.
There is also smbclient if on a Linux OS. it can copy files to a share.
MarKS last edited by MarKS
@SGaist I forgot to mention my app is supposed to work on Win 10. Do I still need to mount the samba share explicitly? Or does windows have native support to access share folders?
Kent-Dorfman last edited by
I forgot to mention my app is supposed to work on Win 10. Do I still need to mount the samba share explicitly? Or does windows have native support to access share folders?
I don't believe Qt does, whether win10 can or not. If it's a file then transport it as a file to a mounted share. You probably don't want to write a Qt specific samba smb/cifs client class.
this <https://stackoverflow.com/questions/25298946/qt-is-there-a-class-for-shared-folders> may have useful information. First result in google search. LOL
Windows understand SMB so if the share is set up correctly
You can use the
copy file.txt \\ip_or_hostname\sharename
However, if the user needed for the shares, is different from the current login user in windows, it will
need to use runas which will not allow you to send a password as a parameter.
In such cases,
you can use
net use x:\ip_or_hostname\sharename /user:username password
Do note that the newest win 10 uses smb3 (protocol version) and will also use v2 on demand but for version smb1 it has to be enabled.
If a newer Linux box it uses smb3 pr default. only something to notice with an older Linux box.
@Kent-Dorfman My bad. I have been through those links but it is already 7 yrs old. Thought there might be improvements to it.
@mrjj This is very resourceful and informative. I got my answer. Thanks!