示例#1
0
        static void MountDrive()
        {
            res = Ff.Current.f_mount(ref fs, "", 1);     /* Give a work area to the default drive */
            res.ThrowIfError();

            Debug.WriteLine("Drive successfully mounted");
        }
示例#2
0
        static void DeleteFileExample()
        {
            res = Ff.Current.f_unlink("/sub1/File2.txt");     /* Give a work area to the default drive */
            res.ThrowIfError();

            Debug.WriteLine("File successfully deleted");
        }
示例#3
0
        static void RenameFileExample()
        {
            /* Rename an object in the default drive */
            res = Ff.Current.f_rename("/sub1/File1.txt", "/sub1/File2.txt");
            res.ThrowIfError();

            Debug.WriteLine("File successfully renamed");
        }
示例#4
0
        static void ListDirectoryExample()
        {
            res = Ff.Current.f_mount(ref fs, "", 1);
            res.ThrowIfError();

            res = Scan_Files("/");
            res.ThrowIfError();

            Debug.WriteLine("Directories successfully listed");
        }
示例#5
0
        static void ReadFileExample()
        {
            if (Ff.Current.f_open(ref Fil, "/sub1/File1.txt", FA_READ) == Ff.FRESULT.FR_OK)
            {                                                                   /* Create a file */
                var newPayload = new byte[5000];
                res = Ff.Current.f_read(ref Fil, ref newPayload, 5000, ref bw); /* Read data from file */
                res.ThrowIfError();

                var msg = Encoding.UTF8.GetString(newPayload, 0, (int)bw);
                Debug.WriteLine($"{msg}");

                res = Ff.Current.f_close(ref Fil);                              /* Close the file */
                res.ThrowIfError();
            }

            Debug.WriteLine("File successfully read");
        }
示例#6
0
        static void CreateFileExample()
        {
            if ((res = Ff.Current.f_open(ref Fil, "/sub1/File1.txt", FA_WRITE | FA_CREATE_ALWAYS)) == Ff.FRESULT.FR_OK)
            {   /* Create a file */
                Random rnd     = new Random();
                var    payload = $"File contents is: It works ({rnd.Next()})!".ToByteArray();
                res = Ff.Current.f_write(ref Fil, payload, (uint)payload.Length, ref bw);    /* Write data to the file */
                res.ThrowIfError();

                res = Ff.Current.f_close(ref Fil);   /* Close the file */
                res.ThrowIfError();
            }
            else
            {
                res.ThrowIfError();
            }

            Debug.WriteLine("File successfully created");
        }
示例#7
0
        static void CreateDirectoriesExample()
        {
            res = Ff.Current.f_mkdir("sub1");
            if (res != FRESULT.FR_EXIST)
            {
                res.ThrowIfError();
            }


            res = Ff.Current.f_mkdir("sub1/sub2");
            if (res != FRESULT.FR_EXIST)
            {
                res.ThrowIfError();
            }

            res = Ff.Current.f_mkdir("sub1/sub2/sub3");
            if (res != FRESULT.FR_EXIST)
            {
                res.ThrowIfError();
            }

            Debug.WriteLine("Directories successfully created");
        }