How to work with alternate file streams on .NET?

andll's Avatar, Join Date: Jul 2007
Light Poster
Good time of day for all!

I have some troubles, and i hope you guys can help me. I search google, but did not find valid answer for my question.

I want to open alternate file streams. If i write something like
File.Open("filename:stramname")
I receive expetion. It says, that file path in this format is not supported in .NET.

Good, i found very simple solution, using CreateFile API and contructor in IO.FileStream class, that receive windows file handle.
But.

I have to use this code in ASP.NET pages, located in the remote server. And, it seems to me, hosting's security policies forbids applications to use Windows API.
Anyway, i recieve <access denided> error, when use any Windows API on the ASP.NET pages, located on the hosting. I do not receive this errors on same code, if it executes on my local machine.

So, i want to ask you: How can i open Stream object for the alternate file stream, without using Windows API?
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
filename:stramname should be a path/
andll's Avatar, Join Date: Jul 2007
Light Poster
Wonderfull, but it does not work.
I wrote:
Quote:
I want to open alternate file streams. If i write something like
File.Open("filename:stramname")
I receive expetion. It says, that file path in this format is not supported in .NET.
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
Write it as File.Open(@"c:\temp.ext") where temp.ext is the actual file path.
andll's Avatar, Join Date: Jul 2007
Light Poster
Oh, you really do not understand me.

Ok, i ask question in another words.

I have stream C:\XXX:ddd

Can you write me there really working code, that opens this strram and reads all of data into string variable?
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
Code:
// create reader & open file
Textreader tr = new StreamReader(@"C:\123.log");
// read a line of text
Console.WriteLine(tr.ReadLine());
// close the stream
tr.Close();
andll's Avatar, Join Date: Jul 2007
Light Poster
This code reads main stream of file C:\123.log
I asked you, how to read file stream C:\XXX:ddd
Can i give me this code, please?
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
You cannot have a file in windows which has : in its name.
andll's Avatar, Join Date: Jul 2007
Light Poster
It is not file. This is alternate file stream(NTFS-stream).
So, i ask how to work with it
rhaazy's Avatar, Join Date: Jul 2007
Go4Expert Member
What you are trying to do requires a seperate class library. Please see this article:

http://www.codeproject.com/cs/files/ads.asp