更新当前文件时更新另一个文件 [英] updating another file when updating current file

查看:94
本文介绍了更新当前文件时更新另一个文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道使用文件更新的想法。如果我有一个名为folder1和folder2的2文件夹,则在这两个文件夹中我创建相同的名称文件,如myfile.txt。如果有任何人更新folder1中的myfile.txt然后自动更新folder2中的myfile.txt。那么,任何人都可以帮助分享逻辑背后的想法吗?

I want to know idea using file updating.if i have a 2 folder named folder1 and folder2, in both folder i create same name file like myfile.txt. if any one update myfile.txt in folder1 then automatically update myfile.txt in folder2. so, can any one help to share idea behind logic?

推荐答案

假设这是C#Winforms,并且PHP引用是假的......



您需要做的第一件事就是检测变化: FileSystemWatcher类 [ ^ ] - 但也要仔细阅读: [ ^ ]

然后它相对简单:如果文件是,则在try ... catch块中的File.Copy忙,如果是,则重试。
Assuming this is C# Winforms, and the PHP reference is spurious...

The first thing you need to do is detect the change: FileSystemWatcher class[^] - but do also read this pretty carefully: FileSystemWatcher - Pure Chaos (Part 1 of 2)[^]
Then it's relatively simple: File.Copy within a try...catch block in case the file is busy, with a retry if it is.


这篇关于更新当前文件时更新另一个文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆