Notification

Icon
Error

File System Reads/Writes to physical hdw
Robert Ridenour
#1 Posted : Wednesday, May 30, 2012 3:23:01 PM(UTC)
Robert Ridenour

Rank: Tinkerer

Joined: 1/28/2011(UTC)
Posts: 25

I have a system with a removable SD card.  I created a log file to log user activity in my application.  In the main application class that extends SPOT.Application there is a method AddLogEntry(string entry) that opens the system.log file and writes the entry and then closes the file.  When displaying a Window object and handling user Touch events a log entry is added by calling the AddLogEntry method of the main application.  What I found is that the log entries do not get physically written to the SD card until the Window object is closed.  Another thread that runs in the background does not exhibit this behavior.  I tried FlushAll() method on the volume and file stream flush to get the data to be actually written to the SD card.  Is there some other method for ensuring writes to the file get written to the SD card?


Also I get an CLR_E_FILE_IO (6) System.IO.IOException when more than one attempt to read file(s) from the file system are made within the same instance of a Window object.  I have a screen that allows a user to select a file from a file list and read the data from the file.  If I select and read one file, and then attempt to either re-read or read a different file the CLR_E_FILE_IO (6) exception occurs.  However if I read a file, close the Window, open a new Window instance then the file system can be read once without and IOException occuring.


I am using V4.1 .NET Microframework.  Thanks for the help in understanding how to use the File System properly.


 

Zach Libby
#2 Posted : Wednesday, May 30, 2012 4:51:08 PM(UTC)
Zach Libby

Rank: Tinkerer

Joined: 2/5/2010(UTC)
Posts: 243

Was thanked: 8 time(s) in 8 post(s)
Hello Robert,

The file system should flush the file to disk when the file is closed. If you are closing the file I am not sure why it would not be flushed (please log a bug on our CodePlex site in this case). The fact that the file flushes when you close the window seems to indicate that the file was not closed/disposed after it was created. Hence closing the window caused the object to be disposed by the GC.

As for your other question, you need to open the file with sharing permissions in order to access it from multiple readers. Use the following method with FileAccess.Read and FileShare.Read for the 3rd and 4th parameters.

public static FileStream Open(String path, FileMode mode, FileAccess access, FileShare share)

Thanks,
Zach
Robert Ridenour
#3 Posted : Tuesday, June 12, 2012 5:21:41 PM(UTC)
Robert Ridenour

Rank: Tinkerer

Joined: 1/28/2011(UTC)
Posts: 25

Zach,


Thanks.  I found that if I remove and re-insert my SD card that the flushes to the SD card file system work always.  It seems that the actual flush or write to the SD card does not occur after I reboot with the SD card inserted.


The most confusing part is that I can run the HTTP Server and FileSystem examples and have no problem after a reboot.


It also seems that my problem has gotten worse as I finished my application, it seems that something along the way broke.  I just don't understand why re-inserting the SD card makes everything work as expected, but on reboot power or soft reboot, it won't work as expected.


Any ideas or thoughts are appreciated.

Rss Feed  Atom Feed
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Powered by YAF | YAF © 2003-2011, Yet Another Forum.NET
This page was generated in 0.057 seconds.