Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C# (http://www.go4expert.com/forums/c-sharp/)
-   -   How to work with alternate file streams on .NET? (http://www.go4expert.com/forums/alternate-file-streams-net-t5210/)

andll 11Jul2007 18:50

How to work with alternate file streams on .NET?
 
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 11Jul2007 19:05

Re: How to work with alternate file streams on .NET?
 
filename:stramname should be a path/

andll 11Jul2007 22:40

Re: How to work with alternate file streams on .NET?
 
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 12Jul2007 09:01

Re: How to work with alternate file streams on .NET?
 
Write it as File.Open(@"c:\temp.ext") where temp.ext is the actual file path.

andll 12Jul2007 12:28

Re: How to work with alternate file streams on .NET?
 
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 12Jul2007 14:23

Re: How to work with alternate file streams on .NET?
 
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 12Jul2007 15:24

Re: How to work with alternate file streams on .NET?
 
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 12Jul2007 18:01

Re: How to work with alternate file streams on .NET?
 
You cannot have a file in windows which has : in its name.

andll 12Jul2007 18:40

Re: How to work with alternate file streams on .NET?
 
It is not file. This is alternate file stream(NTFS-stream).
So, i ask how to work with it

rhaazy 24Jul2007 18:30

Re: How to work with alternate file streams on .NET?
 
What you are trying to do requires a seperate class library. Please see this article:

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


All times are GMT +5.5. The time now is 17:17.