Main Site Documentation

Can't figure out how to read/write file on SD card


#1

I posted my code here, please help

http://code.tinyclr.com/project/386/the-code-fails-to-work-help/

Basically, I write_file() something into a file (sd\hello.txt). i can read_file() the same file to get its contents.

But then after I restart, read_file() reads . It seems that everything has been wiped out of the sd card.

add

I put Thread.Sleep(15000); between FlushAll() and UnmountFileSystem(). Still the same phenomenon.

sorry for the code on tinyclr.com, i will clean it up once the problem is solved :-[


#2

Try putting a sleep after the flush; give it time to complete.


#3

Guys,

the code.tinyclr.com is not a pastebin. Please post your code here or use pastebin.com.

Keep code.tinyclr.com clean please.

Eric


#4

I’m also noticing you’re doing volume[0] which may not be the SD card if, for example, you have a USB drive plugged in, etc. Try getting the correct voulme for the SD off RemovableMediaInsert. And when flushing cycle through all drives.


#5

Here is the output window showing:

Files available on \SD:
\SD\HELLO.TXT

test 1
test 1
end of session

then i restart, the output window still shows the same thing:

Files available on \SD:
\SD\HELLO.TXT
(* should be test 1, which should be written in the file last time *)
test 1
test 1
end of session


#6

@ iammegatron I agree with Eric the code site is not the place to ask code related questions. You are the first who ever did that. Not cool. Let the code site serve the purpose it was created for.

I would remove that entry. You can always put you driver/application/example back once it is working and worth sharing.