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:stream2")
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:\\test.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
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:stream2")
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:\\test.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