Reading a raw data from SD Card
-
Tuesday, April 10, 2012 6:18 AM
Dear all, I am developing the project to read raw data from the 2GB SD Card in C#. My Task is to read raw data from sd-card then put it in the structure and upload it to the data base and then generate the excel files from the data base based on the user inputs. I have searched a lot on the google to get some useful information on how to read raw data from sd card. But i could not found useful one. Can some one give me the right direct on the reading the sd-card raw data.
Thanks a lot.
regards
wep1
I am trying to read the raw data from sd card on PC side.- Edited by wep1 Tuesday, April 10, 2012 6:28 AM
All Replies
-
Tuesday, April 10, 2012 6:19 AM
Dear all, I am developing the project to read raw data from the 2GB SD Card in C#. My Task is to read raw data from sd-card then put it in the structure and upload it to the data base and then generate the excel files from the data base based on the user inputs. I have searched a lot on the google to get some useful information on how to read raw data from sd card. But i could not found useful one. Can some one give me the right direct on the reading the sd-card raw data.
Thanks a lot.
regards
wep1
- Moved by CoolDadTxMVP, Moderator Tuesday, April 10, 2012 5:04 PM Not IDE related (From:Visual C# IDE)
- Merged by Bob ShenMicrosoft Contingent Staff, Moderator Thursday, April 12, 2012 3:10 AM duplicate
-
Tuesday, April 10, 2012 7:28 AM
You need to P/Invoke CreateFile, see the paragraph about Physical Disks and Volumes.- Marked As Answer by Bob ShenMicrosoft Contingent Staff, Moderator Monday, April 23, 2012 4:28 AM
-
Tuesday, April 10, 2012 12:30 PM
Hi wep1.
can you describe the requirements in more detail?
I would expect that any system would use a SD card as a regulard disk and just places a file with raw data on the file system. But from what you wrote it could be understood in a way, that no filesystem is used at all and the data is directly written on the SD disk.
Could you please clarify this point?
In general, you can have these solutions:
1st) This is easy because you are opening the file and read it. The data must be taken in the correct format (which must be specified of course!).
2nd) Thius is a little harder. The core solution in here is to use P/Invoke and then call some functions like CreateFile (http://msdn.microsoft.com/en-us/library/aa363858.aspx).
If you provide more information we could point your further on how to read the file or device.
With kind regards,
Konrad
- Marked As Answer by Bob ShenMicrosoft Contingent Staff, Moderator Monday, April 23, 2012 4:28 AM
-
Monday, April 16, 2012 9:49 AM
Hi Konrad,
Thanks a lot for your reply. I have a SD card which has used in retail billing machine. While doing the all kind of billing, the all data is stored in SD card. That SD card data i have to get on the PC. I am directly trying to access data from SD card on the PC. Their i have to generate the report. But I am not able to read the SD card data itself. Could you please get the sample source code for the same. By the way you are right Konrad, While writing data to the SD card their is not file system available. We are just dumping hex data to the SD card. Please get me some help on the same. Thanks a lot.
Best regards
WeP1
-
Monday, April 16, 2012 11:13 AM
Hi,
I think there might be multiple parts you are interested in:
a) It could be important that your applications is aware of new devices or the removal of devices. There is a project on CodeProject which demonstates how this could work:
http://www.codeproject.com/Articles/18062/Detecting-USB-Drive-Removal-in-a-C-Program
b) next you might want to read the device. From my point of view, CreateFile is the method you should use. The documentation of that function can be found at http://msdn.microsoft.com/en-us/library/aa363858.aspx. PInvoke.net has the signature: http://pinvoke.net/default.aspx/kernel32/CreateFile.html. To Read, ReadFile could be used: http://pinvoke.net/default.aspx/kernel32.ReadFile. Do not forget to close handles that you opened!
With the parts of a and b you should be able to build up your solution. The When the device is inserted, you will get a message which also includes the Dive Name / Path. So you can use that open it and read from it. If you know the name, you can use that directly, too. (I didn't check for a way to list all devices right now.)
With kind regards,
Konrad
- Marked As Answer by Bob ShenMicrosoft Contingent Staff, Moderator Monday, April 23, 2012 4:28 AM
-
Monday, April 16, 2012 5:20 PM
Please check following link it may be useful to you.
http://www.techimo.com/forum/general-tech-discussion/206607-reading-raw-data-off-sd-mmc-card.html
http://www.codeproject.com/Articles/18062/Detecting-USB-Drive-Removal-in-a-C-Program
http://www.pcreview.co.uk/forums/can-read-sd-card-id-similar-information-t3548762.html
- Marked As Answer by Bob ShenMicrosoft Contingent Staff, Moderator Monday, April 23, 2012 4:28 AM

