I have a code written as Windows desktop application. I want to convert it to windows storeapp. However, I could not found equivalent of SafeFileHandle.
Here is the code.
using Microsoft.Win32.Safehandles;
using System;
using System.IO;
using System.Runtime.InteropServices;
internal sealed class FileIO
{
internal const int FILE_ATTRIBUTE_NORMAL = 0x80;
internal const int FILE_FLAG_DELETE_ON_CLOSE = 0x4000000;
internal const int FILE_FLAG_OVERLAPPED = 0x40000000;
internal const int FILE_FLAG_SEQUENTIAL_SCAN = 0x8000000;
internal const int FILE_SHARE_DELETE = 4;
internal const int FILE_SHARE_READ = 1;
internal const int FILE_SHARE_WRITE = 2;
internal const uint GENERIC_READ = 0x80000000;
internal const uint GENERIC_WRITE = 0x40000000;
internal const int INVALID_HANDLE_VALUE = -1;
internal const int OPEN_ALWAYS = 4;
internal const int OPEN_EXISTING = 3;
[DllImport("kernel32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
internal static extern SafeFileHandle CreateFile(string lpFileName, uint dwDesiredAccess, int dwShareMode, IntPtr lpSecurityAttributes, int dwCreationDisposition, int dwFlagsAndAttributes, int hTemplateFile);
}
Microsoft.Win32.Safehandles dll is not supported in Windows Storeapp. It gives error "the type or namespace name Win32 does not exist in the namespace 'Microsoft'(are missing an assembly reference?)"
Therefore, SafeFilehandle gives error like that "The type or namespace name 'SafeFileHandle' could not be found".
Do you have any suggestion?
Thanks.