Unblock File from within .net 4 c#

Based on your input I have done the following code: public class FileUnblocker { [DllImport(“kernel32”, CharSet = CharSet.Unicode, SetLastError = true)] [return: MarshalAs(UnmanagedType.Bool)] private static extern bool DeleteFile(string name); public bool Unblock(string fileName) { return DeleteFile(fileName + “:Zone.Identifier”); } } Thanks to Stuart Dunkeld, Alex K(+1) and Sven to show me the direction. UPDATE I … Read more

How to read and modify NTFS Alternate Data Streams using .NET [closed]

Here is a version for C# using System.Runtime.InteropServices; class Program { static void Main(string[] args) { var mainStream = NativeMethods.CreateFileW( “testfile”, NativeConstants.GENERIC_WRITE, NativeConstants.FILE_SHARE_WRITE, IntPtr.Zero, NativeConstants.OPEN_ALWAYS, 0, IntPtr.Zero); var stream = NativeMethods.CreateFileW( “testfile:stream”, NativeConstants.GENERIC_WRITE, NativeConstants.FILE_SHARE_WRITE, IntPtr.Zero, NativeConstants.OPEN_ALWAYS, 0, IntPtr.Zero); } } public partial class NativeMethods { /// Return Type: HANDLE->void* ///lpFileName: LPCWSTR->WCHAR* ///dwDesiredAccess: DWORD->unsigned int ///dwShareMode: … Read more

tech