Main Site Documentation

SD files accessing problems


#1

When accessing files on the SD card, I get:

  1. the file exists, open to append, get System.ArgumentException
  2. file does not exist, open with OpenOrCreate, get system.argumentexception
    Also:
    file does not exist, open with Create, CreateNew or Open all result in ArgumentException

(could not change original post to include category)


#2

I deleted the old thread. Which boards are you using?


#3

uc5550, ucm revE,UD700


#4

Please post simple piece of code showing the error. Have you seen this? http://docs.ghielectronics.com/software/tinyclr/tutorials/filesystem.html


#5
        if (Mode == LogModes.L_Full || Mode == LogModes.L_Streaming)    // write the datapoints to the file
        {
            LogFileName = "TestData" + DateTime.Now.ToString() + ".csv";
            DataDefs.CF.Open(LogFileName, FileMode.OpenOrCreate);
            DataDefs.CF.WriteStrings(LogEntries);
            DataDefs.CF.Close();
        }

The DataDefs.CF.Open:

    //////////////////////////////////////////////////////////////////////////////
    // Open a file
    //  using filemode
    public bool Open(string filename, FileMode fm)
    {
        this.filename = filename;
        try
        {
            file = new FileStream($@"{drive.Name}{filename}", fm, FileAccess.ReadWrite);
        }
        catch (Exception E)
        {
            Debug.WriteLine(E.Message);
        }
        return true;
    }

#6

Found the problem: The filename has illegal characters