开发者

How to tell if file in one folder is same as file on another folder but has been renamed

开发者 https://www.devze.com 2023-02-25 15:28 出处:网络
I am writing a program to do backups and it will have syncing capabilities. It will be similar to Microsoft\'s SyncToy but it will have much more flexibility and \"group\" backup options etc.

I am writing a program to do backups and it will have syncing capabilities. It will be similar to Microsoft's SyncToy but it will have much more flexibility and "group" backup options etc.

I am using VB.Net 2010 to write the program. The problem I need help with is the efficient comparing of a source file to the destination file when the only difference between a file is the name. (Working on the "Contribute" method of syncing a folder")

In other words if I have a backup folder with a bunch of backed up files and folders from a master source folder and I change the name of one of the files in the master folder, but do nothing else to it, how can I tell that the renamed file is the same as the original named file in the destination folder. In this scenario I would want to rename the destination file to the new name it was given in the master folder instead of just copying the renamed file to the back up folder and ending up with duplicate files of different names needlessly.

Thanks for the help,

Ralph Malph开发者_开发问答


this is the most intelligent approach to sync, sync should be done in 4 major steps 1-compare files in the destination folder and the source folder 2-rename identical files in destination folders and move them to the appropriate sub-folders according to the source folder (no need to copy them over from the source folder) 3-delete files that exist only in the destination folder, 4-copy files that exist only in the source folder

note: no need for cumbersome tracking, no need for a huge log file to record every move you made in the source folder, no need to copy identical files of different names, no need to copy identical files in different sub-folders, all existing sync programs are doing these time wasting activities for nothing

the answers is: there are many effective programs to detect identical files, you can use an open source one in your new sync program


If you want to compare two files you will have to actually compare their content by reading them and comparing a hash of their content, or by performing a byte-by-byte comparison. (You can mitigate this somewhat by first comparing their size)

0

精彩评论

暂无评论...
验证码 换一张
取 消