vb.net - Accessing an MTP device in Visual Basic .NET -
are there libraries available vb.net enable me access mtp device? i'd able find out devices connected, list contents of them , re-create files , them.
everything i've seen far (either @ stack overflow, on microsoft site or simple google search) either in c++, c# or other language isn't vb.net. microsoft documentation goes on head.
as result, it's non-starter unless plan larn new language.
i did find mtpsharp gave me hope. there no documentation, doesn't appear implemented, attempts things homecoming exception , author tells me it's written against old api shouldn't utilize , unable help me questions have.
is there no hope wants utilize vb.net?
a window portable device class lib
note: work of christophe geers series of blogs can found here
i added few functions, vb console test, , converted class lib. tweaked few things in code streamline it, not worth farther mention.
documentation:
study mr geers' blog.
visual studio's intellisense valuable in identifying properties , methods available.
important notescaveat
i have few portable devices (and cant find one), testing rather limited.
files , folders
the term file , folder in context can misleading.
as article makes clear, there portabledeviceobject type (class) both portabledevicefile , portabledevicefolder inherit. portabledeviceobject has property collection named files, collection contains portabledeviceobjects. 1 of items in collection may in fact folder.
i started implement folders collection well, figured out why way is. since folder can contain sub-folders, more confusing , problematic link files subfolders folders portabledevice. so, left it.
this means each item in files collection must tested see whether file or folder. typically done 1 of 2 ways:
' using vb operator if typeof item portabledevicefolder console.beep() end if ' using net type method if item.gettype gettype(portabledevicefolder) console.beep() end if to create things slightly simpler , more object oriented, added isfile , isfolder function portabledeviceobject allows:
if item.isfolder displayfoldercontents(dev, ctype(item, portabledevicefolder)) end if there method returns itemtype enum value (there static version may useful):
' using getitemtype if item.getitemtype = portabledeviceobject.itemtypes.file console.beep() end if resources mr geers' original source
another c# project wpd may useful
msdn windows portable devices documentation more info when ready create mods later.
a vb console app (just translation) shows how utilize of functions. study blog fr details.
the code long, largely duplicate mr geers' blog, , disinclined post code not mine. besides, c# code apparently little if can't compile dll. so, reply question posed, are there libraries available vb.net enable me access mtp device?:
yes. modified source, project files (vs2012), new vb console test app , binaries (portabledevices.dll) can downloaded dropbox. bin/compile folders includes builds anycpu/release , x86/release
interop.* dlls located in folders portabledevice.dll. instance, re-create them both along dll tools directory. not sure why did way. to utilize new class lib in project, need add together reference brand new portabledevice.dll. of course, project source files can load , recompile whatever format desire. vs compiles c# projects same way in vb.
works on machinetm
again, clear, not work. compiled dll.
vb.net dll mtp
No comments:
Post a Comment