|
|||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||
|
Announcements
Chapters
Services
Feature Zones
|
Note: This is an unedited contribution. If this article is inappropriate,
needs attention or copies someone else's work without reference then please
Report This Article
IntroductionADSdotNET is a library which makes it possible for .NET-based programming languages like C# or Visual Basic .NET to access alternate data streams (ADS). Without this DLL it would be neccessary to use P/Invoke or C++/CLI to work with ADS and to benefit from .net-based languages at the same time. ADSdotNET was developed in C++/CLI by the way. The zip file ADSdotNET-0.1.0-src.zip contains a Visual Studio 2005 project. The other zip file (ADSdotNET-0.1.0-bin.zip) contains the compiled DLL only. BackgroundWhen I tried to access ADS from my C# code I found out that the .NET framework currently does not support file streams. So I decided to write a class which I could use for my C# project. I decided to use C++/CLI for writing ADSdotNET because in my opinion using this language for accessing the Windows API is more "natural" than using P/Invoke. Using the codeAfter including the DLL as reference in your Visual Studio project (you can do that in the Solution Explorer) you can see a new entry inside the folder References named ADSdotNET. From now on you can use a new namespace called Now I will describe the methods of the class Overview of all
ConstructorCreates a new object of type C++/CLI declarationAdsHandler(String ^filename);
Parameter
Example 1AdsManager adsman = new AdsManager("C:\\texts\\textfile.txt");
Example 2AdsManager adsman = new AdsManager("C:\\texts");
NoteBy passing an empty string - AddAdsAdds an empty ADS to the root object. C++/CLI declarationvoid AddAds(String ^adsname);
Parameter
Exampleadsman.AddAds("my_stream");
NoteBy passing an empty string - DeleteAdsRemoves (deletes) an ADS from the root object. C++/CLI declarationvoid DeleteAds(String ^adsname);
Parameter
Exampleadsman.AddAds("my_stream");
NoteBy passing an empty string - AdsExistsReturns true if a certain ADS exists, false otherwise. C++/CLI declaration:bool AdsExists(String ^adsname);
Parameter
Exampleif(adsman.AdsExists("stream334")) { ... }
NoteBy passing an empty string - GetAdsListReturns a list of names of all ADS attached to the root object. C++/CLI declarationSystem::Collections::Generic::List<System::String^> ^GetAdsList();
ExampleList<String> adslist = adsman.GetAdsList();OpenAdsOpens an ADS for reading/writing. A C++/CLI declarationSystem::IO::FileStream ^OpenAds(String ^adsname);
Parameter
Example:AdsHandler adsman_folder = new AdsHandler("testfolder");
adsman_folder.AddAds("asd");
System.IO.FileStream fs = adsman_folder.OpenAds("asd");
System.IO.StreamWriter sw = new System.IO.StreamWriter(fs);
sw.WriteLine("Hello ADS!");
sw.Close();
adsman_folder.CloseAds("asd");
Note:If the stream does not exist, a AdsIsOpenedReturns true if an ADS with the name specified is opened at the moment, false otherwise. The stream must have been opened with the method C++/CLI declarationbool AdsIsOpened(String ^adsname);
Parameter
Exampleif (adsman_folder.AdsIsOpened("stream")) { ... }CloseAdsCloses an ADS which was opened by C++/CLI declarationvoid CloseAds(String ^adsname);
Parameter
Example(see GetCompleteFilenameBuilds a name like C++/CLI declaration:
System::String ^GetCompleteFilename(String ^adsname);
Parameter
Examplestring filename = adsman.GetCompleteFilename("stream");
NoteA stream with the name specified does not have to exist. More ResourcesAt http://www.mickbitsoftware.com/de/adsdotnet you can download a pdf file which contains the German version of the text you can read above. AdsManager is an application written in C# which uses ADSdotNET. You can download the binary from http://www.mickbitsoftware.com/en/adsmanager. Currently I do not provide the source code of AdsManager. HistoryVersion 0.1.0 is the initial version of this DLL.
|
||||||||||||||||||||||||||||||||||||||||