I am developing a smart device application in windows mobile 6.5 with .NET CF 3.5 using C#. user will use this application to write xml file to storage card, every day around have 5000 xml files to be written to storage card. but there have a problem I can not find the root reason, that is sometimes write the file is zero size and also can not be opened these zero size files.
using (StreamWriter sw = System.IO.File.CreateText(@"\Storage Card\temp\filename01.xml"))
{
xmldocData.Save(sw);
sw.Flush();
sw.Close();
}
I will grateful if anyone can help?
Is it possible that some of the data you are trying to write is empty?
using (StreamWriter sw = System.IO.File.CreateText(@"\Storage Card\temp\filename01.xml"))
{
if ( sw.BaseStream.Length > 0)
{
xmldocData.Save(sw);
}
sw.Flush();
sw.Close();
}
Its a bit hard to tell, are you able to show some more code around the data you are saving?
Possibly a problem with the SD card or the driver.
Please check the SD card. Use different cards of other vendors to test.
Do not save and change too much on a SD card, they are not designed as a hard disk. See wear-leveling etc. Most consumer cards are designed for normal day-by-day use but not for industrial use.
There are much better Industrial Use SD cards for example by ATP with better wear-leveling etc to allow you to change the 'memory' bytes more often.
See the vendor of your device and ask for a new memory card driver or device firmware or there recommended SD cards.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.