Flush MTP connection with Android tablet?

。_饼干妹妹 提交于 2019-11-29 14:38:32

Use this function of windows as shown by this DELPHI example.


procedure shCopyFile(hWndOwner: HWND; const SourceFile, TargetFile: string);

var Info : TSHFileOpStruct;
Aborted : Bool;

begin
Aborted := False;

with Info do
begin
Wnd := hWndOwner;
wFunc := FO_COPY;

// From Microsoft's Help:
// wFunc = Operation to perform. This member can be one of the following values:
// FO_COPY Copies the files specified by pFrom to the location specified by pTo.
// FO_DELETE Deletes the files specified by pFrom (pTo is ignored).
// FO_MOVE Moves the files specified by pFrom to the location specified by pTo.
// FO_RENAME Renames the files specified by pFrom.

pFrom := pChar(SourceFile);
pTo := pChar(TargetFile);
fFlags := 0;
fFlags := FOF_SILENT or FOF_NOCONFIRMATION or FOF_NOERRORUI;
fAnyOperationsAborted := Aborted;
end;
try
SHFileOperation(Info);
finally
if Aborted then; enact upon any user cancellations
end;
end;

I'm copying file from Desktop to Android MTP device PATH

Stefano www.data-ware.it

I have found exact the same problem on the Samsung Galaxy Tab 2 7.0.

But in my oppinion it is a problem on the android side.

If I force the application which opens the db to stop (System Settings->app manager->my app->force stopp) then it works.

Only "open connection" and "close connection" isn't enough. The complete process on the android-side has to be closed.

This explains why it works after restarting the device.


Further investigation: It works perfectly with Galaxy Tab and 4.1.2 (if App-process is closed). It works with MTP but not PTP (Picture Transfer Protocol). Both protocols are connecting with WPD-function but PTP is quite inconsistent when writing and reading (so never ever use PTP).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!