How to Close SafeFile Handle properly
问题 I am working on a c# project where i communicate with an USB device. I open the connection with: [DllImport("Kernel32.dll", SetLastError = true)] static extern Microsoft.Win32.SafeHandles.SafeFileHandle CreateFile(string filename, [MarshalAs(UnmanagedType.U4)]FileAccess fileaccess, [MarshalAs(UnmanagedType.U4)]FileShare fileshare, int securityattributes, [MarshalAs(UnmanagedType.U4)]FileMode creationdisposition, int flags, IntPtr template); private Microsoft.Win32.SafeHandles.SafeFileHandle