Click here to Skip to main content
Click here to Skip to main content
Articles » Languages » C# » General » Downloads
 
Add your own
alternative version

Accessing alternative data-streams of files on an NTFS volume

, 28 Jul 2010 CPOL
A pair of classes to encapsulate access to NTFS alternative data streams.
ntfsstreams.zip
bin
Trinet.Core.IO.Ntfs.dll
doc
Trinet.Core.IO.Ntfs.chm
Trinet.Core.IO.Ntfs.FxCop
other
Compatibility wrapper
test.jpg
Unblock Files
Trinet.Core.IO.Ntfs
Trinet.Core.IO.Ntfs.sln.cache
Properties
ntfsstreams_src.zip
test.jpg
using System;
using System.IO;
using Trinet.Core.IO.Ntfs;

namespace NTFS
{
	public sealed class StreamInfo
	{
		private readonly AlternateDataStreamInfo _stream;
		
		internal StreamInfo(AlternateDataStreamInfo stream)
		{
			_stream = stream;
		}
		
		public string Name
		{
			get { return _stream.Name; }
		}
		
		public long Size
		{
			get { return _stream.Size; }
		}
		
		public override int GetHashCode()
		{
			return _stream.GetHashCode();
		}
		
		public override string ToString()
		{
			return _stream.ToString();
		}
		
		public override bool Equals(object obj)
		{
			if (object.ReferenceEquals(null, obj)) return false;
			if (object.ReferenceEquals(this, obj)) return true;
			
			StreamInfo info = obj as StreamInfo;
			if (null != info) return _stream.Equals(info._stream);
			
			AlternateDataStreamInfo other = obj as AlternateDataStreamInfo;
			if (null != other) return _stream.Equals(other);
			
			string path = obj as string;
			if (null != path) return string.Equals(path, _stream.FullPath, StringComparison.OrdinalIgnoreCase);
			
			return false;
		}
		
		public FileStream Open(FileMode mode, FileAccess access, FileShare share)
		{
			return _stream.Open(mode, access, share);
		}
		
		public FileStream Open(FileMode mode, FileAccess access)
		{
			return this.Open(mode, access, FileShare.None);
		}
		
		public FileStream Open(FileMode mode)
		{
			return this.Open(mode, FileAccess.ReadWrite, FileShare.None);
		}
		
		public FileStream Open()
		{
			return this.Open(FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None);
		}
		
		public bool Delete()
		{
			return _stream.Delete();
		}
	}
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Richard Deeming
Software Developer Nevalee Business Solutions
United Kingdom United Kingdom
No Biography provided
Follow on   Twitter   Google+

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.141220.1 | Last Updated 28 Jul 2010
Article Copyright 2002 by Richard Deeming
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid