7 Replies - 4878 Views - Last Post: 16 June 2011 - 01:17 AM Rate Topic: -----

#1 ame Umber  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 18
  • Joined: 07-March 11

read and write through USB port

Posted 14 June 2011 - 08:38 PM

hi ...!!!
i need to read and write data through USB port.I want to connect flash drive through my code and read all its data and files. I've searched a lot but couldn't find some relevant example code so that I may write my own.
in fact i am new to c sharp.
i just need some guidance.
thanks!!
Is This A Good Question/Topic? 0
  • +

Replies To: read and write through USB port

#2 Dogstopper  Icon User is offline

  • The Ninjaducky
  • member icon



Reputation: 2870
  • View blog
  • Posts: 11,021
  • Joined: 15-July 08

Re: read and write through USB port

Posted 14 June 2011 - 08:43 PM

Moved to C# help. Please post questions in the help forums and not the tutorials forums.

Thanks! :)
Was This Post Helpful? 0
  • +
  • -

#3 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 8937
  • View blog
  • Posts: 33,462
  • Joined: 12-June 08

Re: read and write through USB port

Posted 14 June 2011 - 08:52 PM

Most recent Windows platforms treat a USB drive as an extra hard drive, right? So you do the same! The same code that writes a file to a spot on the 'c' drive works well when using the assigned drive letter! Nothing too magical about it!
Was This Post Helpful? 2
  • +
  • -

#4 ame Umber  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 18
  • Joined: 07-March 11

Re: read and write through USB port

Posted 15 June 2011 - 05:25 AM

View Postmodi123_1, on 14 June 2011 - 08:52 PM, said:

Most recent Windows platforms treat a USB drive as an extra hard drive, right? So you do the same! The same code that writes a file to a spot on the 'c' drive works well when using the assigned drive letter! Nothing too magical about it!


wow awesome ....you've made my work pretty easy.
so you want to say if i just gget the drive name through my code i may read and write data just like we send data to other ports i.e. serial ports etc..???
but in fact I want to get USBs unique id i.e. product id and vendor id too.
Was This Post Helpful? 0
  • +
  • -

#5 tlhIn`toq  Icon User is online

  • Please show what you have already tried when asking a question.
  • member icon

Reputation: 5436
  • View blog
  • Posts: 11,653
  • Joined: 02-June 10

Re: read and write through USB port

Posted 15 June 2011 - 06:28 AM

No. What he is saying is forget about this being ports of any kind.

You write to a USB flash drive just exactly the same as if it were your C: harddrive.

It is all standard System.IO commands.

if (System.IO.File.Exists(myFilePath))
{
   // Then do something
}


The only difference is that instead of a path from C: it is a path for whatever letter is your flash drive. F: or whatever.

There is plenty of documention on the web about getting the product ID and so on.

Give it a try. Show us your good faith effort to try to code your solution per the DIC guidelines. If you run in to trouble then post the code with errors/exception back here in this same thread.
Was This Post Helpful? 1
  • +
  • -

#6 ragingben  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 170
  • View blog
  • Posts: 637
  • Joined: 07-October 08

Re: read and write through USB port

Posted 15 June 2011 - 08:37 AM

ame Umber - are you trying to read and write files? If so the above answers are great.

I got the impression from the original post that you are trying to use USB for another purpose. There are many USB wrappers such as this (although I have tried none of them) that allow you to use USB in other ways - for example streaming to a extrenal device (at work we use RS232 to communicate to PIC micro-processors), but if this is what your after I guess C++ would be a better language for this kind of lower level stuff.
Was This Post Helpful? 0
  • +
  • -

#7 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6036
  • View blog
  • Posts: 23,421
  • Joined: 23-August 08

Re: read and write through USB port

Posted 15 June 2011 - 09:31 AM

Quote

I want to connect flash drive through my code and read all its data and files


Nope, trying to read and write files.
Was This Post Helpful? 0
  • +
  • -

#8 ame Umber  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 18
  • Joined: 07-March 11

Re: read and write through USB port

Posted 16 June 2011 - 01:17 AM

View Postragingben, on 15 June 2011 - 08:37 AM, said:

ame Umber - are you trying to read and write files? If so the above answers are great.

I got the impression from the original post that you are trying to use USB for another purpose. There are many USB wrappers such as this (although I have tried none of them) that allow you to use USB in other ways - for example streaming to a extrenal device (at work we use RS232 to communicate to PIC micro-processors), but if this is what your after I guess C++ would be a better language for this kind of lower level stuff.


no in fact i want to read and write some file from flash drive to any other hard drive C etc and from C or D drive to flash drive..... just like we send our data

View PosttlhIn`toq, on 15 June 2011 - 06:28 AM, said:

No. What he is saying is forget about this being ports of any kind.

You write to a USB flash drive just exactly the same as if it were your C: harddrive.

It is all standard System.IO commands.

if (System.IO.File.Exists(myFilePath))
{
   // Then do something
}


The only difference is that instead of a path from C: it is a path for whatever letter is your flash drive. F: or whatever.

There is plenty of documention on the web about getting the product ID and so on.

Give it a try. Show us your good faith effort to try to code your solution per the DIC guidelines. If you run in to trouble then post the code with errors/exception back here in this same thread.



okay thank you so much.. you have made my work bit easy....
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1