I'm developing an application using file transfer, developed in C#, .NET SDK (v. 5.5).
The application, for the sake of this post, just opens up a FileTransferVirtualThing with a virtual folder mapped. All file transfers initiated from the ThingWorx platform fail.
It seems to be linked to the physical directory of the file transfer. If the virtual directory is mapped to "C:\temp" it works, if mapped to "D:\temp" it doesn't. However both directories exist, permissions have been reset multiple times, directory deleted and recreated, etc.
I've tried other directories and the result is the same - what it seems to make a difference, oddly, is the drive : C: works, D: doesn't. Of course both are hard disks, online, etc.
Now, I'm probably missing some trivial piece but asking here anyway .. is there any reason why file transfers to C: drive would work and D: would fail ?
Ok I peeked into the C SDK source code and I think I found the problem.
In twWindows.c, function twDirectory_MoveFile there is this line:
res = MoveFileExW(from, to, MOVEFILE_REPLACE_EXISTING | MOVEFILE_WRITE_THROUGH);
Windows SDK documentation says:
When moving a file, the destination can be on a different file system or volume. If the destination is on another drive, you must set the MOVEFILE_COPY_ALLOWED flag in dwFlags.
Since ThingWorx uses C:\opt\... as a temporary storage for file transfers and then moves the file when completed, the move will fail as it's on another volume and the flag has not been specified, thus the reason why all transfers to a non-C: volume fail.