Alternate File Streams or Alternate Data Streams

M

mcr

Hi.


As some of you might know you can use alternate file streams in
windows.


read more here: http://www.robvanderwoude.com/index.html (Search for "NTFS
Alternate File Streams")


My problem is that I can not get this to work from C#. No mater what I
do I get a NotSupportedException.


I have been testing with three code snippets:


This requires that the file c:\test.txt exists.

XmlDocument newFile = new XmlDocument();
newFile.Load((@"c:\test.txt:st­ream2")
XmlNode root = newFile.DocumentElement;
-----
StreamWriter newFile = File.CreateText(@"c:\test.txt:­stream2");
newFile.WriteLine("Stream 2");
newFile.Close();
-----
string lines = "First line.\r\nSecond line.\r\nThird line.";
System.IO.StreamWriter newFile = new
System.IO.StreamWriter("c:\\te­st.txt:stream2");
newFile.WriteLine(lines);
newFile.Close();
-----


As I said, these three tests all gives me a NotSupportedException.


Ok I know that it is becaues of the colon ":" in the path string, but if you
do
this from windows using for example notepad it works fine.


First create a new file called c:\test.txt then:
notepad c:\test.txt:stream2
Write something and save. Now you have two files in one.


So its seems that some of the .NET classes dont accept the colon ":" in
the path syntax.


Does someone know a way around this? Maybe using some others funtions
or methods to to open the file. Or is it not supported by the framework it
self.

anyone know this?


Thanks, Martin
 
J

Joerg Jooss

mcr said:
Hi.


As some of you might know you can use alternate file streams in
windows.


read more here: http://www.robvanderwoude.com/index.html (Search for
"NTFS Alternate File Streams")


My problem is that I can not get this to work from C#. No mater what I
do I get a NotSupportedException.

Hm... I don't think that this particular NTFS feature is supported by
system.IO.

Cheers,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top