Media Devices is a API to interact with MTP (Media Transfer Protocol), PTP (Picture Transport Protocol) and MSC (Mass Storage Class) devices like cell phones, tablets and cameras.
Future: NuGet Package
You are welcome to support this project.
MTP Library
License: MIT License
Media Devices is a API to interact with MTP (Media Transfer Protocol), PTP (Picture Transport Protocol) and MSC (Mass Storage Class) devices like cell phones, tablets and cameras.
Future: NuGet Package
You are welcome to support this project.
Awesome library - I have a quick question:
I'm using MediaDevices.DownloadFile() to download video files from a device. Sometimes these files can be rather large, upto 1GB in size. I'd love to know, is there any way to get download progress from the device?
If there's any way of having a callback to report download progress - that would be awesome or if you can even point me to where I might be able to add this to your project, be happy to write and submit a pull request.
After UploadFolder call the names of the containing folders in the first level are missing 1st character.
Describe the bug
call device.connect() will wait forever after call 'MediaDevice.DeleteFile', and windows explorer can not show any disk and file. it will be recover after pull out device from computer
To Reproduce
device.Connect();
device.DeleteFile("Any file exists in device");
device.Disconnect();
Expected behavior
can call device.connect() again and windows exploer can work correctly
Device
Samsung Galaxy Note 10, SM-N9700, Android 10
Version:
1.9.1
Additional context
Regards
Describe the bug
MediaDevice.GetFiles() Unable to get full file name on some special name
To Reproduce
file name exists in media device : princess_connect!_re:dive skirt_lift tail.jpg
call method MediaDevice.GetFiles(), get file name : dive skirt_lift tail.jpg
Calling MediaDevice.GetFileInfo() with an incomplete file name will cause an exception that the file does not exist.
Expected behavior
This file name is legal in Android. hope to get the complete file name
Device
Sanmsung Galaxy Note 10, SM-N9700
Version:
1.9.1
Would it be possible to add Stream OpenWrite()
method to the MediaFileInfo
class in the same fashion as the Stream OpenRead()
is? That would allow us e.g. to use CopyToAsync()
for writing to the MTP device.
I am working on abstraction in my project which uses pure Streams for both download/upload transfers across multiple types of devices, so currently I will need to find some workaround, since only the void UploadFile(Stream stream, string path)
is available at the moment (as far as I searched the library code).
Hello Bassman2,
after my successful performance experiments in #7 using a Windows 7 x64 PC I wanted to repeat the same for my main machine running Windows 10 (v1803) x64.
However, my WPF application always crashes during the run with the following exception.
An unhandled exception of type 'System.AccessViolationException' occurred in mscorlib.dll
Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
Sadly I haven't been able to catch this exception or any corresponding callstack at all and I don't really know, which operations actually fails.
The test does the following:
root.EnumerateFileSystemInfos("*", SearchOption.AllDirectories)
MediaFileInfo
handle for each file in a listMediaFileInfo.CopyTo
The exception always triggers during this run but sometimes during phase 2 and during phase 3.
One thing I was able to determine: the issue only appears after commit 436ab2e which included the "64-bit fix" for #6. Using the commit before ( 01a6e6a) works fine (albeit slow).
To be honest: I'm uncertain about the code changes you implemented then and what they actually affect. Do you have any suggestions on how to analyze this appropriately?
Best regards,
tale
We are calling MediaDevice.GetDevices() in our program from different threads (but never at the same time) and have noticed that only the first call (from the main thread) provides a complete list of all connected (Android) devices. Although all subsequent calls return a list with the correct number of MediaDevice objects, only the first object of this list is completely filled/initialized correctly. All subsequent objects are uninitialized, the DeviceId and Manufacturer fields are null.
Does something have to be considered when calling MediaDevice.GetDevices() from different threads?
Sorry for being a novice, but how do I code an eventhandler to pick up when a device has been removed?
I can't see any examples anywhere.
Apologies in advance, I'm struggling to grok all of this. Anyway, I have a very small test project using the Avalonian UI (which I've used before to create windows/mac common source projects). This one works fine on windows, and doesn't on macos.
Note on loading project on the mac, I get the message:
/Users/t/Documents/Projects/Tm2/Tm2.csproj: Warning NU1701: Package 'MediaDevices 1.8.0' was restored using '.NETFramework,Version=v4.6.1, .NETFramework,Version=v4.6.2, .NETFramework,Version=v4.7, .NETFramework,Version=v4.7.1, .NETFramework,Version=v4.7.2, .NETFramework,Version=v4.8' instead of the project target framework '.NETCoreApp,Version=v3.0'. This package may not be fully compatible with your project. (NU1701) (Tm2)
in debug, the statement "var devices = MediaDevice.GetDevices();"
produces a System.TypeInitialization Exception with an innerexception of {System.PlatformNotSupportedException: COM is not supported}
Describe the bug
System.Reflection.TargetInvocationException
COMException: 没有群集资源。 (异常来自 HRESULT:0x8007138E)
To Reproduce
call method CopyThumbnail on an none thumbnail file such as .rmvb video file, will cause Exception
Expected behavior
no exception
Device
Samsung galaxy Note 10, SM-N9700, Android 10
Version:
1.9.1
Additional context
Consider add a method to check the file has thumbnail or not
i found this article today, and i'm trying to use example at starting page
( about createdirectory(@"\Phone\Documents\Temp"). but i have some problem.
when i using that code, exception appeared about invalid_datatype at createdirectory.
how can i fix them?
i tried device.EnumerateDirectories(@"\Phone\Documents"), but it works well.
and using with galaxy s8.
var devices = MediaDevice.GetDevices();
var myphonename;
using (var device = devices.First(d => d.FriendlyName == myphonename))
{
device.Connect();
device.CreateDirectory(@"\Phone\Documents\Temp");
using(FileStream stream = File.OpenRead(@"C:/Temp/Test.txt"))
{
device.UploadFile(stream, @"\Phone\Documents\Temp\Test.txt");
}
device.Disconnect();
}
Hi i have recently started using this library and its great and easy to use. The only issue i have had is that the list of attached devices returned by MediaDevices.GetDevices() does not update if a device is plugged in/removed while my application is running.
I also get an error when i mount a drive after launching the application (null exception while enumerating GetDrives()
Cheers
I am trying to use this library to send 0x101B (GetPartialObject) request to MTP device and than read the data. I can't find the way to do that. What the inputParams should be? How to read the received data?
Thank you.
Hi Bassman2,
first of all thank you very much for that awesom library.
I have to questions for you:
Thank you again
Hi Ralf
First: great work! Thanks a lot.
Now my "problem":
I have to find and grab all multimedia files (mp4, mp3, jpg, png, gif, wav, ...).
With the given method EnumerateFiles() I only able to search for one extension at a time. e.g. device.GetRootDirectory().EnumerateFiles("*.jpg"). That means I have to do that more or less manually for all files I want to grab.
It would be nice, if there is a way to do it like this:
device.GetRootDirectory().EnumerateFiles("*.jpg|*.png|*.mp4")
or
device.GetRootDirectory().EnumerateFiles(new string[] { "*.jpg", "*.png" })
Thanks for your service
See https://ci.appveyor.com/project/chcg/mediadevices/build/job/eipos0gctt9u16mh
CSC : error CS2001: Source file 'C:\projects\mediadevices\MediaDevicesShare\Internal\IStream.cs' could not be found. [C:\projects\mediadevices\MediaDevicesCore30\MediaDevicesCore30.csproj]
CSC : error CS2001: Source file 'C:\projects\mediadevices\MediaDevicesShare\Internal\IStream.cs' could not be found. [C:\projects\mediadevices\MediaDevicesCore20\MediaDevicesCore20.csproj]
CSC : error CS2001: Source file 'C:\projects\mediadevices\MediaDevicesShare\Internal\IStream.cs' could not be found. [C:\projects\mediadevices\MediaDevicesFramework45\MediaDevicesFramework45.csproj]oj]
I was testing out the MediaDevice.DownloadFile method as it was used in your Unit Test:
using (MemoryStream stream = new MemoryStream())
{
device.DownloadFile(filePath, stream);
position = stream.Length;
using (FileStream file = File.Create(localPath))
{
stream.Position = 0;
stream.CopyTo(file);
}
}
And I keep getting a NotImplementedException:
at System.Runtime.InteropServices.ComTypes.IStream.Stat(STATSTG& pstatstg, Int32 grfStatFlag)
at MediaDevices.StreamWrapper.get_Length()
at System.IO.Stream.GetCopyBufferSize()
at MediaDevices.MediaDevice.DownloadFile(String path, Stream stream)
at TestAndroidFileTransfer.Program.Main(String[] args) in C:\Users\Jonathan\source\testrepos\TestAndroidFileTransfer\TestAndroidFileTransfer\Program.cs:line 26
Have you seen this issue before? It is not immediately apparent what is going on..
Hey Bassman,
I have once again a question about your NuGet. Is there a way to monitor the gallary for changes, like adding an Image or deleting one?
Thanks in advance,
Daniel
Is your feature request related to a problem? Please describe.
A potential blocking problem because WUDFHost.exe will cache the file list in MTP device when first connect to the device.
Describe the solution you'd like
Set before open the MTP device
CLSID_WPD_NAMESPACE_EXTENSION ("{35786D3C-B075-49B9-88DD-029876E11C01}")
Add this to MediaDevice.Connect()
clientInfo.SetStringValue(ref WPD.CLIENT_EVENT_COOKIE, "{35786D3C-B075-49B9-88DD-029876E11C01}");
Describe alternatives you've considered
Explorer use this flag to notify WUDFHost.exe not to cache any file list when we connect to the MTP device. That could be helpful if WUDFHost.exe takes a long time to get the whole list, which will block any operation until it release the lock. It's an important value and that's why explorer will never be blocked by WUDFHost.exe
Additional context
Delay is obviously after we call MediaDevice.DeleteFile(). Set this policy will solve this issue.
Hello Bassman2,
For my mobile device backup-tool, I am using your library, which works perfect. But when I upload a file to the mobile device using the UploadFile
method, I noticed that for the last write time of the fileinfo, the timestamp on which the file was copied is used. If I copy the file directly (using the Windows Explorer), the timestamp of the creation-date from the source-file will be used. Since I am comparing these timestamps in order to create a differential backup, this issue is causing me some difficulties.
I am not sure if it is a bug or just limited by Win MTP. But is there a possibility to subsequently override the "last write time" of a file (simillar to the File.SetLastWriteTime
method) on the mobile device?
Best regards,
Ben
Hey Bassman,
I just want to know if it is possible to download the files from the mobile phone async?
Sorry I'm still new to github and also wanted to know if theres an another way to ask questions, since this one isn't really an Issue.
Thanks in advance
Daniel
Hi Ralf,
We have successfully integrated this library in our application and it is working pretty well.
While testing this with various devices, sometimes we see COMException while getting downloading file from the device though the file path is valid.
System.Runtime.InteropServices.COMException (0x80004005): Error HRESULT E_FAIL has been returned from a call to a COM component. at MediaDevices.Internal.IPortableDeviceResources.GetStream(String pszObjectID, PropertyKey& key, UInt32 dwMode, UInt32& pdwOptimalBufferSize, IStream& ppStream) at MediaDevices.Internal.Item.OpenRead() at MediaDevices.MediaDevice.DownloadFile(String path, Stream stream) at MTPDevice.<ImportData>d__a.MoveNext()
We are wondering if you have seen this issue at some point or if there is some workaround or fix.
Any help is welcomed!
Thanks & Regards
Pallavi Garg
Library version: 1.8.0.0 (from Nuget, but tried building the latest version from sources too)
Operating system: Windows 7/10
.NET Framework: 4.5
Made the minimum number of operations:
After the last step, the application completely freezes until I unplug the device (tried different phones, the behaviour is the same). Moreover, if I try to open Explorer, it will freeze too. If there are a lot of files, then the program manages to delete some of them.
Because of what it can be and is it possible to fix it somehow?
Thank you!
Platform .NET Framework 4.5.2 / 4.6.1, C#, WinForms
Issue:
If application start with device connected, no issue.
Hi Ralf,
I need to have MediaDevices package to be a strongly named assembly. Is there any signed version available? If not, how do you suggest to sign it?
Thanks & Regards,
Pallavi Garg
Hi, thank you for spend time to make this great project.
I got error about InteropServices.COMException when run on x64 CPU,
after call MediaDevice.Connect(), I cannot get info about SerialNumber, it throw exception.
Could you help me ?
Tks so much !
Hey,
I am working on a program to manage pictures on a mobile device. So far everything works fine and I love this NuGet. But I noticed that in .NetCore 3.1 the functions "DownloadFile" and "DownloadFileFromPersistentUniqueId" get a "NotImplementedException". I have already seen that enantiomer2000 started an issue for this, but it was not answered / fixed.
So please could you take a look at it.
Thanks in advance.
-Daniel
I has two device, when I call MediaDevice.GetDevices in a task the second device will become null. If I call in the same thread context MediaDevice.GetDevices return value is normal.
Test code:
private static readonly object _lock_pad = new object();
private void Test()
{
// second device is null
var devices = MediaDevice.GetDevices();
}
private void button1_Click(object sender, EventArgs e)
{
Task.Run(() =>
{
lock (_lock_pad)
{
for (var i = 0; i < 5; i++)
{
Test();
}
}
});
lock (_lock_pad)
{
for (var i = 0; i < 10; i++)
{
// when click alwarys normal return value
var devices = MediaDevice.GetDevices();
}
}
}
It alse throw exception int Output window says:
System.Runtime.InteropServices.COMException (0x800706F4): 向占位程序传送了空的索引指针。 (异常来自 HRESULT:0x800706F4)
在 MediaDevices.Internal.IPortableDeviceManager.GetDeviceDescription(String pszPnPDeviceID, StringBuilder pDeviceDescription, UInt32& pcchDeviceDescription)
在 MediaDevices.MediaDevice..ctor(String deviceId)
System.Runtime.InteropServices.COMException (0x800706F4): 向占位程序传送了空的索引指针。 (异常来自 HRESULT:0x800706F4)
在 MediaDevices.Internal.IPortableDeviceManager.GetDeviceFriendlyName(String pszPnPDeviceID, StringBuilder pDeviceFriendlyName, UInt32& pcchDeviceFriendlyName)
在 MediaDevices.MediaDevice..ctor(String deviceId)
System.Runtime.InteropServices.COMException (0x800706F4): 向占位程序传送了空的索引指针。 (异常来自 HRESULT:0x800706F4)
在 MediaDevices.Internal.IPortableDeviceManager.GetDeviceManufacturer(String pszPnPDeviceID, StringBuilder pDeviceManufacturer, UInt32& pcchDeviceManufacturer)
在 MediaDevices.MediaDevice..ctor(String deviceId)
'向占位程序传送了空的索引指针' may translate as 'a null reference pointer was passed to the stub'
.Net Framework 4.7.2
MediaDevices 1.8.0
Thanks!
There seems to be a memory leak somewhere in file retrieval.
using System;
using System.Linq;
using MediaDevices;
namespace MediaDevicesLeakRepro {
class Program {
static void Main(string[] args) {
foreach (var device in MediaDevice.GetDevices()) {
device.Connect();
while (true) {
device.EnumerateFileSystemEntries("/").First();
GC.Collect(100, GCCollectionMode.Forced, true, false);
GC.WaitForPendingFinalizers();
}
}
}
}
}
When device is attached and has a drive, this code will leak unmanaged memory, in all version from 1.7 to 1.5. In 1.4 this no longer happens.
GC is there just to confirm that there really is a leak and it isn't just a lazy GC.
I suspect that this causes serious problems during certain file operations, especially when the device itself adds/removes/changes files at the same time, but this is currently only a hunch. This leak caused my application to crash with out of memory error, after leaving it running for a while.
It could be somehow related to #13, but that is just a speculation.
Hi! Are you planning on making a .NET Core version of your library? Thanks
Hello,
I have noticed that using a MemoryStream with UploadFile is about 10 times slower than using a filestream. In below example I am copying 500 5MB files to an MTP device either with a FileStream or with a MemoryStream. Note that the FileStream is converted to the MemoryStream in both cases so the conversion time does not matter.
var devices = MediaDevice.GetDevices();
if (devices.Count() > 0)
{
var device = devices.First();
device.Connect();
var stopwatch = new System.Diagnostics.Stopwatch();
stopwatch.Start();
foreach (var file in Directory.GetFiles(@"C:\TestFiles"))
{
string filename = Path.GetFileName(file);
Console.WriteLine(filename);
MemoryStream ms = new MemoryStream();
FileStream fs = File.OpenRead(file);
fs.CopyTo(ms);
ms.Position = 0;
fs.Position = 0;
//uncomment one to test
//device.UploadFile(ms, Path.Combine(@"Internal shared storage\TestFiles", filename));
//device.UploadFile(fs, Path.Combine(@"Internal shared storage\TestFiles", filename));
ms.Close();
fs.Close();
}
stopwatch.Stop();
Console.WriteLine(stopwatch.Elapsed);
}
For my usecase I need to use memory streams is there a possible workaround?
Hi,
We are using MediaDevices to iterate over any usb device connection via usb port. Please refer to below log from Event Viewer. We use ManagementEventWatcher to detect device attachment.
Application was running and this fatal issue happened just after connecting device with system. This is not very frequent issue, so won’t be able to provide more details.
If someone has fixed or handled this issue, please let us know. Any help would be much appreciated!
Log-
Faulting application name: DummyName.exe, version: 1.1.2.54, time stamp: 0x5dd3fe20
Faulting module name: PresentationCore.ni.dll, version: 4.8.4018.0, time stamp: 0x5d4a6c7c
Exception code: 0xc0000005
Fault offset: 0x0067876d
Faulting process id: 0x3050
Faulting application start time: 0x01d5a3a6a32299f8
Faulting application path: C:\Program Files (x86)\DummyName.exe
Faulting module path: C:\WINDOWS\assembly\NativeImages_v4.0.30319_32\PresentationCore\431135a1fa749be763773e77963c87b4\PresentationCore.ni.dll
Report Id: 8cffc963-5e5f-4fca-adbf-f2dc3244f83c
Thanks
Pallavi Garg
Hi,
I need to filter out only mobile devices ie, android phones connected on USB port. I tried using MediaDevice.DeviceType, but it does not give "DeviceType.Phone" value.
For onePlus, pen drive it gave - DeviceType.Generic
For Samsung phone it gave - DeviceType.MediaPlayer
Is there any way to actually filter these devices?
Best
Pallavi
could someone tell me how to download a thumbnail of a image?
i want to download the thumbnail not the image first;
Describe the bug
Device cannot EnumerateFiles when reconnected. It gives exception "System.Runtime.InteropServices.COMException (0x802A0002): Shutdown was already called on this object or the object that owns it. (Exception from HRESULT: 0x802A0002)"
To Reproduce
Expected behavior
It should connect and enumerate files or any other operation.
Device
Any MTP device
Version:
1.9.1
Additional context
Add any other context about the problem here.
I would like to be able to Checksum a given file in a given location. Can this be part of the MediaFileInfo class? I tried to implement this but I was not successful.
Problematic scenario:
Result: Every invocation after the first throws COMException with HRESULT 0x800704C7.
No-problem scenario:
Result: Everything works fine.
I use the second scenario as a workaround, but there might be some COM object marshaling problems in the library (I'm not familiar with COM interop).
Tested with MediaDevices 1.9.1, .NET 4.7.2, x86 profile, Windows 10 21H2 and Samsung Galaxy J5.
Hi there!
Before I ask, the effort spent on that library is incredible, I respect it a lot.
I'm creating a photo explorer for MTP devices. The explorer must show image thumbnails as fast as possible. Currently I'm facing the biggest problem with performance. I'm trying to load images in explorer as fast as possible, but min time to get usable files tream is 70ms - 140ms. You can imagine that when loading e.g. 25 images it takes about 2.5s. It is a lot, when you have thousands of pictures on mobile phone, and you want to browse images. My target would be Windows Explorer loading performance. I cannot get, how they did it?
I wonder if this delay is because of .NET wrapper? C++ solutions are much faster, e.g. I saw pictures browser written in Qt where thumbnail were loaded as fast as in win. explorer.
I was checking you code, I see some small improvements, to skip some wrapping code of getting children objects without wrapping them up in Item etc. But I doubt it will help...
Did you have maybe similar situation, or have you some ideas how to load thumbnails of images AFAP?
Any help is welcome!
PS: You can close this issue if it breaks you issue statistics... It is not a bug or problem. Just another use case.
All best,
Paul
OS Win 7 x64
.Net Framework 4.5.1
MediaDevices 1.9.0 (from github)
I use 1.8.0 from Nuget first and that worked well till I hit a road block in using the function
OpenReadFromPersistentUniqueId()
Now I'm using 1.9.0, with worked will for an hour or so, and then i'm getting this exception.
I can manually access images and videos on the Camera via windows explorer.
I tried restarted the computer, however that didn't change anything.
I need to retrieve the path to my phone from the computer to copy/paste backup files to it.
After adding the nuget package to unity, it can't find my devices.
So I have this error:
NullReferenceException: Object reference not set to an instance of an object
MediaDevices.MediaDevice.GetDevices () (at <016781043aa441d5b0169b9d5116ee77>:0)
ManageSaves.CopySaveFromDevice () (at Assets/Scripts/ManageSaves.cs:65)
ManageSaves.Testing () (at Assets/Scripts/ManageSaves.cs:57)
MainMenu.Testing () (at Assets/Scripts/MainMenu.cs:69)
UnityEngine.Events.InvokableCall.Invoke () (at <23a7799da2e941b88c6db790c607d655>:0)
UnityEngine.Events.UnityEvent.Invoke () (at <23a7799da2e941b88c6db790c607d655>:0)
UnityEngine.UI.Button.Press () (at C:/Program Files/Unity/Hub/Editor/2019.3.14f1/Editor/Data/Resources/PackageManager/BuiltInPackages/com.unity.ugui/Runtime/UI/Core/Button.cs:68)
UnityEngine.UI.Button.OnPointerClick (UnityEngine.EventSystems.PointerEventData eventData) (at C:/Program Files/Unity/Hub/Editor/2019.3.14f1/Editor/Data/Resources/PackageManager/BuiltInPackages/com.unity.ugui/Runtime/UI/Core/Button.cs:110)
UnityEngine.EventSystems.ExecuteEvents.Execute (UnityEngine.EventSystems.IPointerClickHandler handler, UnityEngine.EventSystems.BaseEventData eventData) (at C:/Program Files/Unity/Hub/Editor/2019.3.14f1/Editor/Data/Resources/PackageManager/BuiltInPackages/com.unity.ugui/Runtime/EventSystem/ExecuteEvents.cs:50)
UnityEngine.EventSystems.ExecuteEvents.Execute[T] (UnityEngine.GameObject target, UnityEngine.EventSystems.BaseEventData eventData, UnityEngine.EventSystems.ExecuteEvents+EventFunction`1[T1] functor) (at C:/Program Files/Unity/Hub/Editor/2019.3.14f1/Editor/Data/Resources/PackageManager/BuiltInPackages/com.unity.ugui/Runtime/EventSystem/ExecuteEvents.cs:261)
UnityEngine.EventSystems.EventSystem:Update() (at C:/Program Files/Unity/Hub/Editor/2019.3.14f1/Editor/Data/Resources/PackageManager/BuiltInPackages/com.unity.ugui/Runtime/EventSystem/EventSystem.cs:377)
A possible solution... that you know ?
Is there a way to get a list of files with the size and date info for each because calling GetFileInfo for each file is very slow?
I published a console app using your library which helps back up contents of a media device (iPhone) to another storage repository. Anyone that wants to use it as reference or as a baseline for their own app, please feel free to do so. https://github.com/jchristn/PhotoSync
Thank you so much for producing this outstanding library!
Do you think it would be possible to start an application, like Chrome or youtube ?
Hi!
Thank You for this great library!
I would like to use the NuGet package (1.8.0) in a .NET Core 2.2 application but i get this warning:
D:\GitHub\---\---.csproj : warning NU1701: Package 'MediaDevices 1.8.0' was restored using '.NETFramework,Version=v4.6.1' instead of the project target framework '.NETCoreApp,Version=v2.2'. This package may not be fully compatible with your project.
I am not really familiar with multi-targeting but could this be fixed with that so NuGet could automatically restore as a .NET Core 2.1 library instead of a .NET Framework 4.6.1?
I added this repository as a submodule to temporary fix this warning.
Hi
Os Win 7
.Net Framework 4.5.1
Media Devices DLL Version 1.8.0 (Downloaded from NuGet)
I'm trying to copy a large video file from a DSLR camera, and at the same time show a progress bar in WinForms, C#.
I try to use this method
using (Stream srcStream = device.OpenReadFromPersistentUniqueId(mediainfo.PersistentUniqueId)) {
}
However when I try to access the "Length" property of the Stream it throws an exception saying "Not Implemented"
Is this by design?
I can see other methods in the Documentation like DownloadFile, however they read the whole file into the stream and I don't have control to show a progress bar.
I see that "OpenReadFromPersistentUniqueId" is the most suitable since it returns a Stream to the underlying file.
Am I missing something here!
Thanks in advance.
Hello. I like your MTP Library.
But I can't get some value..
That is..
I was replace your some code, but there are not connected error..
If you can add this logic, I feel so good.
Thank you Bass man.
public static PropertyKey WPD_STORAGE_CAPACITY = new PropertyKey(0x01A3057A, 0x74D6, 0x4E80, 0xBE, 0xA7, 0xDC, 0x4C, 0x21, 0x2C, 0xE5, 0x0A, 4);
public static PropertyKey WPD_STORAGE_FREE_SPACE_IN_BYTES = new PropertyKey(0x01A3057A, 0x74D6, 0x4E80, 0xBE, 0xA7, 0xDC, 0x4C, 0x21, 0x2C, 0xE5, 0x0A, 5);
Hi,
I'm using MediaDevices 1.8.0 on .NET 4.5, connected MTP devices are Android phones (tried Android 4.3, 7.0 and 9).
API hangs are discovered in the following situations, when trying to access a filepath after its file has been deleted:
Example 1:
MediaDevice.DeleteFile(filepath)
if MediaDevice.FileExists(filepath) then ...
The DeleteFile method will correctly delete the file on the device but the FileExists method will not produce a result nor an exception. Instead program execution goes into hang within the method.
Eventually the processing will continue after 3 minutes or so but typically nothing happens for at least 5 minutes.
Same behaviour has been observed when the UploadFile method is used after the DeleteFile.
Interestingly, renaming the file before delete will not help.
Example 2:
MediaDevice.RenameFile(filepath, newfilename)
MediaDevice.DeleteFile(newfilepath)
if MediaDevice.FileExists(filepath) then ...
RenameFile renames the file and DeleteFile also works as expected, but FileExists will hang in this situation again - both when used on filepath as well as on newfilepath.
Without the DeleteFile line, the FileExists method works fine after RenameFile (false on filepath and true on newfilepath).
Has this behaviour been recognized before?
Thanks and best regards
Kai
Describe the bug
I'm using the plugin to copy files from a connected USB camera to disk. Everything works great. But for each file I try to copy to the disk, I get a NotImplementedException printed on the console. The program is not interrupted and each file seems to be copied correctly. But I'm unsure if there are any further downsides?
Exception:
System.NotImplementedException: The method or operation is not implemented. at System.Runtime.InteropServices.ComTypes.IStream.Seek(Int64 dlibMove, Int32 dwOrigin, IntPtr plibNewPosition) at MediaDevices.Internal.StreamWrapper.Seek(Int64 offset, SeekOrigin origin)
To Reproduce
The following code snippet logs the exception on console:
Device.DownloadFile(filePathOld, filePathNew);
It also happens if I implement the streamwriter on my own.
Expected behavior
There shouldn't be an exception on the console.
Device
Microsoft Windows 10 21H1 64bit
Version:
MediaDevices 1.9.1 (NuGet package)
Additional context
IDE: Visual Studio Community 2019
Project: .NetCore 3.1
Target platform: win-x64
Thanks for this awesome library 👍 . Really like to see the NuGet package repo gets updated with latest fixes and enhancements.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.