コード例 #1
0
    public static bool FlushVolume(string volumeName, ILogger logger)
    {
        bool   flag = false;
        IntPtr file = Win32Utils.CreateFile(volumeName, 3221225472U, 3U, IntPtr.Zero, 3U, 0U, IntPtr.Zero);

        if (file.ToInt32() != -1)
        {
            if (!Win32Utils.FlushFileBuffers(file))
            {
                logger.Warning("Failed to flush this mount point: " + volumeName);
                logger.Warning("Flush error: " + (object)Marshal.GetLastWin32Error());
            }
            else
            {
                logger.Information("Successfully flushed mount point: " + volumeName);
                flag = true;
            }
        }
        else
        {
            logger.Warning("Failed to open a valid handle to " + volumeName + " Could not flush!!");
        }
        return(flag);
    }