How to empty/flush Windows READ disk cache in C#?

后端 未结 5 2060
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-01 13:12

If I am trying to determine the read speed of a drive, I can code a routine to write files to a filesystem and then read those files back. Unfortunately, this doesn\'t give

5条回答
  •  我在风中等你
    2020-12-01 14:11

    const int FILE_FLAG_NO_BUFFERING = 0x20000000;
    return new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read,64 * 1024,
    (FileOptions)FILE_FLAG_NO_BUFFERING | FileOptions.Asynchronous
    & FileOptions.SequentialScan);
    

提交回复
热议问题