简体   繁体   中英

File.Copy() function

Does anyone know how the function File.Copy() is implemented? I need to know if the file is copied using TCP connection.

Thanks, Haviva.

It uses the native Win32 method CopyFile in kernel32.dll. Files are copied over the normal file system or over SMB (which was correctly pointed out to use TCP by mjmarsh).

Or as Scott Dorman correctly adds it can use the CreateFile method also in kernel32.dll.

It's at a deeper level than that. File.Copy will call the Windows API to perform the copy. If you happen to have TCP as your primary protocol on your machine's network stack, it will use TCP. If Windows decides to use another protocol, it will use that one instead. So if your network configuration sets Banyan VINES as your default protocol and you have disabled TCP ;-), File.Copy won't use TCP.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM