检查Cocoa中的两个文件是否相同

检查Cocoa中的两个文件是否相同

本文介绍了检查Cocoa中的两个文件是否相同的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何有效地检查Cocoa中两个文件是否相同(具有相同的数据)?

How do you efficiently check if two files are the same (have the same data) in Cocoa?

上下文:我正在编写一个接收文件的程序作为输入(输入文件),并将其复制到目录中。如果目录已经包含具有相同名称的文件(同名文件),则只有当该名称文件不同时,才应使用新名称复制输入文件。

Context: I'm writing a program that receives a file as input (input file) and copies it into a directory. If the directory already contains a file with the same name (namesake file) then the input file should be copied with a new name only if the namesake file is different.

推荐答案

可以使用 - [NSFileManager contentsEqualAtPath:andPath:]

文档:

这篇关于检查Cocoa中的两个文件是否相同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-30 14:40