I'm working on a Cosmos operatingsystem, and I'm wondering if there is some way to write a file with information in it? I'm trying to make CosmosOS remind the username and the password.
PS. I also wan't it to be able to read the file.
Currently only FAT is supported, so you need at least one FAT partition. In your BeforeRun
method, you need to initialize the VFS, like this:
var fs = new Sys.FileSystem.CosmosVFS();
Sys.FileSystem.VFS.VFSManager.RegisterVFS(fs);
Then you can use the System.IO
APIs to read and write files. The root path for the first partition is 0:\
.
public override void BeforeRun()
{
var fs = new Sys.FileSystem.CosmosVFS();
Sys.FileSystem.VFS.VFSManager.RegisterVFS(fs);
}
public override void Run()
{
var usersFile = @"0:\users.dat";
if (!File.Exists(usersFile))
{
File.Create(usersFile);
}
// now you can read or write to the file
// example read methods: File.ReadAllText, File.ReadAllLines, File.ReadAllBytes
// example write methods: File.WriteAllText, File.WriteAllLines, File.WriteAllBytes
}