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!!
read and write through USB port
Page 1 of 17 Replies - 2829 Views - Last Post: 16 June 2011 - 01:17 AM
Replies To: read and write through USB port
#2
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!
Thanks!
#3
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!
#4
Re: read and write through USB port
Posted 15 June 2011 - 05:25 AM
modi123_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.
#5
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.
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.
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.
#6
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.
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.
#7
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.
#8
Re: read and write through USB port
Posted 16 June 2011 - 01:17 AM
ragingben, 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.
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
tlhIn`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.
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.
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....
Page 1 of 1
|
|

New Topic/Question
Reply




MultiQuote










|