Main Site Documentation

Directory.Move(sourceDirectory, destinationDirectory);


Using: Libs version 1.0.0-preview2 and 1.0.0-preview3 - Neither worked for Move

I have been trying to use Directory.Move(sourceDirectory, destinationDirectory);

I never receive exceptions in Try Catch.

Maybe I am the problem but I thought I would let you know anyway.

            //StorageController sc
            if (sc == null) 
                sc = StorageController.FromName(@"GHIElectronics.TinyCLR.NativeApis.STM32F7.SdCardStorageController\0");
                drive = FileSystem.Mount(sc.Hdc);

            //These directories already exist on the SD Card. Each has a small text file in the folder

            DirectoryInfo di0 = new DirectoryInfo($@"{drive.Name}FolderToMove");
            DirectoryInfo di1 = new DirectoryInfo($@"{drive.Name}FolderToMoveTo");

            if (di0.Exists && di1.Exists)
                string sourceDirectory = $@"{drive.Name}FolderToMove";
                string destinationDirectory = $@"{drive.Name}FolderToMoveTo";

                    // Tried both ways - No exceptions received using either one
                    //Directory.Move(sourceDirectory, destinationDirectory);
                    Directory.Move(di0.Name, di1.Name);
                    // No exceptions received
                    screen.DrawString("Directory.Move ERROR", droidreg12, BrushRed, 450, 210);
                screen.DrawString(di0.Name + " & " + di1.Name + " do not exist.", droidreg12, BrushRed, 405, 182);


We’ll take a look and let you know what we find


Thanks. Not really a problem. I just thought I would let you know.

I was not sure if it was an error in my test code.


Thanks for pointing things out. Please do not feel like you can’t share anything you find with us. We are here to help and make TinyCLR the best it can be :slight_smile:


Did you remember call FileSystem.Flush before take SD out?

Also, destination folder must be not exist. Following your example, I think you want is inside di1.Name, it should be:

‘Directory.Move(di0.Name, di1.Name\;’


Thank you for the reply.

I had the destination folder on the card before using move.