![]() |
VOOZH | about |
dotnet add package Trinet.Core.IO.Ntfs --version 4.1.3
NuGet\Install-Package Trinet.Core.IO.Ntfs -Version 4.1.3
<PackageReference Include="Trinet.Core.IO.Ntfs" Version="4.1.3" />
<PackageVersion Include="Trinet.Core.IO.Ntfs" Version="4.1.3" />Directory.Packages.props
<PackageReference Include="Trinet.Core.IO.Ntfs" />Project file
paket add Trinet.Core.IO.Ntfs --version 4.1.3
#r "nuget: Trinet.Core.IO.Ntfs, 4.1.3"
#:package Trinet.Core.IO.Ntfs@4.1.3
#addin nuget:?package=Trinet.Core.IO.Ntfs&version=4.1.3Install as a Cake Addin
#tool nuget:?package=Trinet.Core.IO.Ntfs&version=4.1.3Install as a Cake Tool
A library for working with alternate data streams on NTFS file systems from .NET applications.
Originally published on CodeProject
Now available as a NuGet package: https://www.nuget.org/packages/Trinet.Core.IO.Ntfs/
Install-Package Trinet.Core.IO.Ntfs
Since NT 3.1, the NTFS file system has supported multiple data-streams for files. There has never been built-in support for viewing or manipulating these additional streams, but the Windows API functions include support for them with a special file syntax: Filename.ext:StreamName. Even Win9x machines can access the alternative data streams of files on any NTFS volume they have access to, e.g., through a mapped drive. Because the Scripting.FileSystemObject and many other libraries call the CreateFile API behind the scenes, even scripts have been able to access alternative streams quite easily (although enumerating the existing streams has always been tricky).
In .NET, however, it seems someone decided to add some checking to the format of filenames. If you attempt to open a FileStream on an alternative stream, you will get a "Path Format not supported" exception. I have been unable to find any class in the CLR that provides support for alternative data streams, so I decided to roll my own.
The AlternateDataStreamInfo class represents the details of an individual stream, and provides methods to create, open, or delete the stream.
The static FileSystem class provides methods to retrieve the list of streams for a file, retrieve a specific stream from a file, determine whether a stream exists, and delete a specific stream.
All methods on the FileSystem class offer overloads which accept either a path or a FileSystemInfo object. The overloads which accept a FileSystemInfo object can also be invoked as extension methods.
using System;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using Trinet.Core.IO.Ntfs;
...
FileInfo file = new FileInfo(path);
// List the additional streams for a file:
foreach (AlternateDataStreamInfo s in file.ListAlternateDataStreams())
{
Console.WriteLine("{0} - {1} bytes", s.Name, s.Size);
}
// Read the "Zone.Identifier" stream, if it exists:
if (file.AlternateDataStreamExists("Zone.Identifier"))
{
Console.WriteLine("Found zone identifier stream:");
AlternateDataStreamInfo s = file.GetAlternateDataStream("Zone.Identifier", FileMode.Open);
using (TextReader reader = s.OpenText())
{
Console.WriteLine(reader.ReadToEnd());
}
// Delete the stream:
s.Delete();
}
else
{
Console.WriteLine("No zone identifier stream found.");
}
// Alternative method to delete the stream:
file.DeleteAlternateDataStream("Zone.Identifier");
This code was inspired by Dino Esposito's MSDN article from March 2000: http://msdn.microsoft.com/en-us/library/ms810604.aspx
Copyright (c) 2002-2025 Richard Deeming All rights reserved.
This code is free software: you can redistribute it and/or modify it under the terms of either
This code is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 net5.0 was computed. net5.0-windows net5.0-windows was computed. net6.0 net6.0 was computed. net6.0-android net6.0-android was computed. net6.0-ios net6.0-ios was computed. net6.0-maccatalyst net6.0-maccatalyst was computed. net6.0-macos net6.0-macos was computed. net6.0-tvos net6.0-tvos was computed. net6.0-windows net6.0-windows was computed. net7.0 net7.0 was computed. net7.0-android net7.0-android was computed. net7.0-ios net7.0-ios was computed. net7.0-maccatalyst net7.0-maccatalyst was computed. net7.0-macos net7.0-macos was computed. net7.0-tvos net7.0-tvos was computed. net7.0-windows net7.0-windows was computed. net8.0 net8.0 was computed. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 was computed. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 was computed. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 netcoreapp2.0 was computed. netcoreapp2.1 netcoreapp2.1 was computed. netcoreapp2.2 netcoreapp2.2 was computed. netcoreapp3.0 netcoreapp3.0 was computed. netcoreapp3.1 netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 netstandard2.0 is compatible. netstandard2.1 netstandard2.1 was computed. |
| .NET Framework | net35 net35 is compatible. net40 net40 was computed. net403 net403 was computed. net45 net45 was computed. net451 net451 was computed. net452 net452 was computed. net46 net46 was computed. net461 net461 was computed. net462 net462 is compatible. net463 net463 was computed. net47 net47 was computed. net471 net471 was computed. net472 net472 was computed. net48 net48 was computed. net481 net481 was computed. |
| MonoAndroid | monoandroid monoandroid was computed. |
| MonoMac | monomac monomac was computed. |
| MonoTouch | monotouch monotouch was computed. |
| Tizen | tizen40 tizen40 was computed. tizen60 tizen60 was computed. |
| Xamarin.iOS | xamarinios xamarinios was computed. |
| Xamarin.Mac | xamarinmac xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos xamarinwatchos was computed. |
Showing the top 3 NuGet packages that depend on Trinet.Core.IO.Ntfs:
| Package | Downloads |
|---|---|
|
NINA.Plugin
Package Description |
|
|
HorizonReports.Api
Horizon Reports Api for use from plugin projects. |
|
|
BatchImageLoaderLibrary
Batch image loader with on-disk and SQLite caching. |
Showing the top 9 popular GitHub repositories that depend on Trinet.Core.IO.Ntfs:
| Repository | Stars |
|---|---|
|
nefarius/ScpToolkit
Windows Driver and XInput Wrapper for Sony DualShock 3/4 Controllers
|
|
|
Snoothy/UCR
Universal Control Remapper [Alpha]
|
|
|
Pscx/Pscx
PowerShell Community Extensions module repository
|
|
|
ShokoAnime/ShokoServer
Repository for Shoko Server.
|
|
|
isbeorn/nina
N.I.N.A. (Nighttime Imaging 'N' Astronomy) - Advanced astrophotography sequencing software for Windows, supporting full automation of imaging sessions.
|
|
|
Rambalac/ACDDokanNet
Dokan.NET based driver for Amazon Cloud Drive
|
|
| TehCheat/PoEHUD | |
|
nefarius/Shibari
Gaming input peripherals prototyping platform for Windows
|
|
|
jfmaes/SharpLNKGen-UI
UI for creating LNKs
|
##4.1.3.0
### BUG FIXES:
* Fixed the long path prefix for UNC paths to use `\\?\UNC\` instead of just `\\?\`.
## 4.1.2.0
### IMPROVEMENTS:
* Added Create, CreateText, and AppendText methods to the AlternateDataStream class.
* Switched to Microsoft.NETFramework.ReferenceAssemblies to allow building withing Framework 3.5 installed.
* Enabled reproducible builds.
* Enabled source link.
##4.1.1.0
### IMPROVEMENTS:
* Multi-targeting for .NET Standard 2.0, .NET Framework 4.6.2, and .NET Framework 3.5;
### BUG FIXES:
* Accessing ADS on directories with a trailing slash no long throws an exception.
* No longer adds the long path prefix if the path is already prefixed.
##4.0.0.0
### IMPROVEMENTS:
* The assembly now has a strong name.
##3.5.0.1
### BUG FIXES:
* Fixes a bug where zero-length alternate streams prevented other streams from being enumerated.