InvaidOperationException Filsystem

I’m currently trying to get the filesystem demo working on an external SSD that I have on hand. It’s a 500Gb Samsung drive formatted to exFat.

When I attempt to mount the filesystem, the InvalidOperationExcecption is thrown, and I don’t really know what’s going on. The DeviceconnectionEventArgs read just fine, as well. I’ve pasted the snippet of my code where the exception is being thrown below, any help is appreciated.

Additionally, I’m new to how you’re supposed to interact with a filesystem like this. My goal is to simply have the ability to write .bin/.txt files to the drive at the very least. If anyone has recommended reading or videos to this, that would be great too.

Is this a hint?


File System The file system library is subset of the full .NET file system support. Most example should work with without minor changes. The internal drivers fully support FAT16 or FAT32 file systems, with no limitations beyond the FAT file system itself! USB Mass Storage This allows file access on USB devices with MSC class, such as USB memory sticks. See the USB page. SD Card SD and MMC cards are fully supported as detailed on the SD tutorial page. The example below requires the GHIElectronics.TinyCLR.IO

Are you suggesting that exFat does not fit into FAT16 or FAT32? Other than that, I mount the filesystem the same way as the demo does here, and the demo does in the USB tutorial.

Exfat, NTFS, FAT12 and others are not supported. Only FAT16 and FAT32 are supported.

1 Like

My hint was a bit stronger than a suggestion but short of a absolute statement. :grinning:

But Gus is the absolute authority. He is also kind of cute…


@Mike @Gus_Issa That makes sense, I’ve reformatted the drive to be in FAT32. I’m running into an issue when attempting to execute the non-static write function on the Filestream object. What’s interesting is that the exception being thrown is from the GHIElectronics.TinyCLR.IO.dll, while I was under the impression that until the FileSystem.flush line, the filestream business was currently from default C#. I’ve posted a screenshot of my code and error below, and I’m using this tutorial from GHI File System, now with FAT32 drive. The “drive info section” from the USB tutorial works just fine now.

Did you looked at the bytes you are trying to write?

It’s from the UtcNow Method, Here is what I got:

Here’s the bytes using the BitConverter.ToString method:

And here is the UTF8 toString version
01/01/2017 00:00:23

I still can’t quite figure out what’s going wrong.

I ran your code with a USB thumb drive and it worked without any issue.

I believe that TinyClr, and the Sitcore hardware, supports USB 1 not USB 2. Perhaps the drive you are using does not like USB 1?

The drive I used is at least five years old.

I suggest you try a few other drives to see if the problem is a drive compatibly issue.

You can send us the drive you have and we can fix for you. Without having a non-working device we can’t spot/fix the issue.

Also, when formatting the drive, what allocation unit did you specify?

@Mike when you say USB 1, I take it you mean the USB 1.0 protocol? If so, I thought new versions of SITCore were designed to support fast USB transfer (as their old filesystem specific chips had USB phy implementations), which leads me to believe that USB 2.0 at the very least would be supported. @Gus_Issa The drive is a relatively new Samsung “portable SSD” line that has a single 20GB partition in FAT32 allocated, though its full capacity is 500 GB, the rest is unallocated for the purposes of my testing. I’m not attached to USB flash storage over SD flash storage, but final implementation has to be extremely vibration resistant, and SD cards generally don’t fit that bill.

I believe it is USB 1.0, but Gus should have the final word on this.

I would try formatting the SSD to the full 500GB to see if that is the issue. I have never tried a partitioned device.

It is USB 2 running at 12mbps. The easiest way to see what is going on is by having one connected to our analyzer. Otherwise we are simply guessing.

@Mike problem with that is then can’t format in FAT32, right? At least in Windows, I had to drop the size down to under 32GB before FAT32 formatting was allowed. @Gus_Issa is the analyzer a program or are you referring to something at home base?

I thought max partition size for FAT32 was 2TB?

I believe you can do it in windows using command line. And there are tools you can download top format.

But I do not think this is the problem.

@Mike @Gus_Issa I’m gonna get my hands on a USB 2.0 drive tomorrow and see if that affects anything. Thanks for the tip about the command line Gus, will update.

1 Like