Unmounting USB Drive/s

If you need help with a project or need to know how to do something specific in VB.NET then please ask your questions in here.
Forum rules
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
11 posts Page 1 of 2
Contributors
User avatar
hungryhounduk
VIP - Site Partner
VIP - Site Partner
Posts: 2870
Joined: Mon Jul 27, 2009 11:58 am

Unmounting USB Drive/s
hungryhounduk
Hey Peeps

I am making an app that reads USB Devices, I have the accessing USB devices running fine,and the Formatting of Devices, But How do i code my app to Unmount USB Devices?? Like you do normally on the taskbar, But i want mine coded on a Button..

Can anyone help?

150 Credits for the First Working answer cooll; That someone can give me..

Cheers

Chris
Image
User avatar
MrAksel
C# Coder
C# Coder
Posts: 1758
Joined: Fri Mar 26, 2010 12:27 pm

Re: Unmounting USB Drive/s
MrAksel
This is not my code. It is completely taken from http://stackoverflow.com/questions/7704 ... ia-c-sharp. I just converted it.

If the listbox is empty, you have no devices you can eject. Else, select an item and click the button. You can see the results if you have explorer open.
You do not have the required permissions to view the files attached to this post.
LMAOSHMSFOAIDMT
Laughing my a** of so hard my sombrero fell off and I dropped my taco lmao;


Over 30 projects with source code!
Please give reputation to helpful members!

Image
Image
User avatar
hungryhounduk
VIP - Site Partner
VIP - Site Partner
Posts: 2870
Joined: Mon Jul 27, 2009 11:58 am

Re: Unmounting USB Drive/s
hungryhounduk
Hey MrAksel

My version of VB is incompatable with the Source you uploaded :(

Can you convert it to VB 10 OR 11 ?

Chris
Image
User avatar
Codex
Coding God
Coding God
Posts: 2028
Joined: Wed Mar 31, 2010 5:50 pm

Re: Unmounting USB Drive/s
Codex
hungryhounduk wrote:
Hey MrAksel

My version of VB is incompatable with the Source you uploaded :(

Can you convert it to VB 10 OR 11 ?

Chris
Open the folder USB Devices and open the following file: USB Devices.vbproj
(Not the .sln file)
We shall let the revolution begin.. the revolution for freedom, freedom against censorship. We shall fight in the fields and in the streets, we shall fight in the hills; we shall never surrender
User avatar
hungryhounduk
VIP - Site Partner
VIP - Site Partner
Posts: 2870
Joined: Mon Jul 27, 2009 11:58 am

Re: Unmounting USB Drive/s
hungryhounduk
Hey Codex
Its be coded for 4.5 framework and i cannot open it on my machine

Chris
Image
User avatar
Codex
Coding God
Coding God
Posts: 2028
Joined: Wed Mar 31, 2010 5:50 pm

Re: Unmounting USB Drive/s
Codex
hungryhounduk wrote:
Hey Codex
Its be coded for 4.5 framework and i cannot open it on my machine

Chris
Try this: http://speedy.sh/Ph3Cn/3.5-Version.zip
I thought the 2008 version is same as 2010 one, since in 2010 it asks you if you want to retarget for .NET 4.0

(The credit goes to MrAksel's link)
We shall let the revolution begin.. the revolution for freedom, freedom against censorship. We shall fight in the fields and in the streets, we shall fight in the hills; we shall never surrender
User avatar
MrAksel
C# Coder
C# Coder
Posts: 1758
Joined: Fri Mar 26, 2010 12:27 pm

Re: Unmounting USB Drive/s
MrAksel
Im sorry. I forget that VS 11 defaults to .NET 4.5. You should be able to open the .vb files though and add it to another project. You could add the USBEject.vb file to any solution, then use this to eject a device:
Code: Select all
Dim eject As New USBEject("F:\") 'No matter if you enter F:\, F: or just F"
If Not eject.Eject() Then MessageBox.Show("Something failed")
LMAOSHMSFOAIDMT
Laughing my a** of so hard my sombrero fell off and I dropped my taco lmao;


Over 30 projects with source code!
Please give reputation to helpful members!

Image
Image
User avatar
hungryhounduk
VIP - Site Partner
VIP - Site Partner
Posts: 2870
Joined: Mon Jul 27, 2009 11:58 am

Re: Unmounting USB Drive/s
hungryhounduk
Try this: http://speedy.sh/Ph3Cn/3.5-Version.zip
I thought the 2008 version is same as 2010 one, since in 2010 it asks you if you want to retarget for .NET 4.0

(The credit goes to MrAksel's link)
Hey that link is not working


I will try what MrAksel says above and let you know if it works ok

Chris
Image
User avatar
Codex
Coding God
Coding God
Posts: 2028
Joined: Wed Mar 31, 2010 5:50 pm

Re: Unmounting USB Drive/s
Codex
hungryhounduk wrote:
Try this: http://speedy.sh/Ph3Cn/3.5-Version.zip
I thought the 2008 version is same as 2010 one, since in 2010 it asks you if you want to retarget for .NET 4.0

(The credit goes to MrAksel's link)
Hey that link is not working


I will try what MrAksel says above and let you know if it works ok

Chris
Click the link and then click the "3.5 Version.zip" link.
Image
Here is a mirror if for some reason that website doesn't load: http://www.mediafire.com/?3vce2vpov27ysk4
We shall let the revolution begin.. the revolution for freedom, freedom against censorship. We shall fight in the fields and in the streets, we shall fight in the hills; we shall never surrender
User avatar
hungryhounduk
VIP - Site Partner
VIP - Site Partner
Posts: 2870
Joined: Mon Jul 27, 2009 11:58 am

Re: Unmounting USB Drive/s
hungryhounduk
Hey

Ok it worked of sorts ;)

If i have a USB Stick attached, it will recognise it

If i select my drive letter in the list and click the button, the USB stick blinks.

iF I exit and restart it's not visible in the list

But

The Icon on the Taskbar is still showing and I still have to eject it manually by clicking the icon and doing it the normal way.......So having done it once with the program, I have to do it again...

Is there any way to just do it once and close the Icon on the taskbar at the same time??

Chris
Image
11 posts Page 1 of 2
Return to “Coding Help & Support”