So I have tried using trinet core io ntfs dll to get to alternative data streams in C# (using VS 2015), but I have a problem: i couldn't find a way to write into a file. The code I tried:
var fileinfo = new FileInfo(filename);
var altstream = fileinfo.GetAlternateDataStream("key").OpenWrite();
altstream.WriteLine(Convert.ToString(radix));
altstream.WriteLine(Convert.ToString(push));
altstream.WriteLine(Convert.ToString(mult));
altstream.WriteLine(Convert.ToString(fill));
It just throws an error message before debug:
'FileStream' does not contain a definition for 'WriteLine' and no extension method 'WriteLine' accepting a first argument of type 'FileStream' could be found (are you missing a using directive or an assembly reference?)
How should I do it? I can't find this on the web but need the use of alternative data streams for my project.
altstreamis aFileStreaminstance.FileStreamonly understands bytes, not strings. In order to convert strings (characters) to bytes, you have to pick a character encoding system, for instance Ascii, UTF8, UTF16, etc.Once you've picked an encoding, you can use the
StreamWriterclass to be able to directly write strings to files: