File.Copy vs. Manual FileStream.Write For Copying File

后端 未结 8 1870
悲&欢浪女
悲&欢浪女 2020-11-27 04:41

My problem is in regards file copying performance. We have a media management system that requires a lot of moving files around on the file system to different locations inc

8条回答
  •  一向
    一向 (楼主)
    2020-11-27 05:10

    Dusting off reflector we can see that File.Copy actually calls the Win32 API:

    if (!Win32Native.CopyFile(fullPathInternal, dst, !overwrite))
    

    Which resolves to

    [DllImport("kernel32.dll", CharSet=CharSet.Auto, SetLastError=true)]
    internal static extern bool CopyFile(string src, string dst, bool failIfExists);
    

    And here is the documentation for CopyFile

提交回复
热议问题