Try getting the file stream this way;
System.IO.FileStream file = System.IO.File.OpenWrite("file.txt");
Or this way (used long form for namespace on both of these);
System.IO.FileStream filealt = new System.IO.FileStream("file.txt", System.IO.FileMode.OpenOrCreate, System.IO.FileAccess.Write, System.IO.FileShare.Write);
I’m wondering if the directory check (exists) is creating a temporary lock on the file which isn’t clearing prior to writing data. NETMF docs say if the current pointer to a file changes unexpectedly you’ll get an exception on write; since it’s in the same Lock() if the Exist() call touches that file and hasn’t cleared prior to writing (which there might be some latency on USB file systems especially on a dirty FAT32 file system that’s been fragmented and written from a lot), then you might be trying to write before the lock from Exist releases.
Just stabbing at the dark here. But at least there’s a few other methods to try, and perhaps move the Exist() outside of the critical code section where you’re locking that section from outside processes?