Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.
Photo

Issue with Create Directory

sd card create directory

  • Please log in to reply
4 replies to this topic

#1 David Weaver

David Weaver

    Advanced Member

  • Members
  • PipPipPip
  • 50 posts
  • LocationBloomington IL

Posted 04 December 2015 - 08:26 PM

Bug in Directory.CreateDirectory? 
 
When I use the function and then remove the SD card and put it in my computer the directory is not created.
 
If I make a call to the function syncroot the new directory is created and saved to the SD card.
 
The code below seems to work.
 
Directory.CreateDirectory("\SD\Temp)
 
 
Dim df() As String = Directory.GetDirectories("\SD\")
 
 
Dim d As Object = CObj(df.SyncRoot)
         For Each e In d
        Debug.Print(e.ToString)
        Next
 
Making the call to syncRoot saves the directory? Anyone else have this problem?
 


#2 KiwiDev

KiwiDev

    Advanced Member

  • Members
  • PipPipPip
  • 100 posts
  • LocationNew Zealand

Posted 05 December 2015 - 02:36 AM

Hi David,

 

Try doing a "flush" to force all updates to the SD card

 

Microsoft.SPOT.IO.VolumeInfo("\\sd").FlushAll();

 

Regards

 

@KiwiBryn

blog.devmobile.co.nz



#3 David Weaver

David Weaver

    Advanced Member

  • Members
  • PipPipPip
  • 50 posts
  • LocationBloomington IL

Posted 05 December 2015 - 12:19 PM

Good morning kiwBryn or afternoon New Zealand is a long way from Illinios,

 

After adding a reference to Microsoft.SPOT.IO the code below works in vb version 4.3 using the Netduino 3.

 

 Dim vf As New Microsoft.SPOT.IO.VolumeInfo("\SD")
 vf.FlushAll()
 
The call seems to be similar to the  syncroot above. Do you know if one is better to use than the other?

 

Thanks for the help


#4 KiwiDev

KiwiDev

    Advanced Member

  • Members
  • PipPipPip
  • 100 posts
  • LocationNew Zealand

Posted 05 December 2015 - 08:05 PM

Hi David,

 

Currently NZ is UTC+13 Illinois is UTC-6 so your answers are coming from tomorrow :-)

 

Rolling sunrise global support

 

 

I had a look at the NetMF source on github

 

HRESULT FAT_FS_Driver::FlushAll( const VOLUME_ID* volume ) 

   FAT_LogicDisk* logicDisk = FAT_MemoryManager::GetLogicDisk( volume ); 
 
   if(logicDisk) 
   { 
      logicDisk->SectorCache.FlushAll(); 
 
      return S_OK; 
   } 
 
   return CLR_E_INVALID_DRIVER; 
 

When I follow this in it writes sectors out to the media which is what I would expect.

 

On the otherhand

 

public Object SyncRoot 
   get { return this; } 
 
Which is a multi threading synchronisation primitive.
 
Not certain why synchronising access to an in memory array of string containing directory names would force writing to SD .
 
@KiwiBryn
blog.devmobile.co.nz


#5 David Weaver

David Weaver

    Advanced Member

  • Members
  • PipPipPip
  • 50 posts
  • LocationBloomington IL

Posted 05 December 2015 - 10:01 PM

Hello kiwBryn, (I won't pretend to even know what day it is :) )

 

This is the code I am using may be over kill be it seems to work every time?

 

If Directory.Exists("\SD\Scenes") = False Then

            Debug.Print("Creating Scenes")
            Directory.CreateDirectory("\SD\Scenes")
            Thread.Sleep(10)
            Dim df() As String = Directory.GetDirectories("\SD\")
            Dim d As Object = df.SyncRoot
            Thread.Sleep(10)
            'Need reference to microsoft.spot.io.dll
            Dim vf As New Microsoft.SPOT.IO.VolumeInfo("\SD")
            vf.FlushAll()
            Thread.Sleep(10)
        End If
 
You have a much bettter understanding of the operating system. What I would like to do is access the MFDeploy engine to write a simple Visual Studio 2005 vb program to set the Wi-Fi variables for Netduino 3 Wi-Fi. The project I am working on requires MFDeploy. MFDeploy has more steps than my users may be able to complete successfully. 
 
Thanks again for your help






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.