N
N
needhelpqq2018-03-15 18:55:39
C++ / C#
needhelpqq, 2018-03-15 18:55:39

How to track file changes, and roll back changes if necessary c#?

In general, on the coursework, they asked me to write a program that will track files in a folder that have changed and make backups on them, with the ability to return to the old version of the file .. Tell me how this can be implemented ???

Answer the question

In order to leave comments, you need to log in

4 answer(s)
#
#, 2018-03-15
@needhelpqq

1 - FileSystemWatcher of course .. 2 - but here you need to catch that the watcher will report that the file has been changed ... that there was an opportunity to roll back
to something there - it is necessary that a backup copy already exists before the change ... then - create think, try

L
lvv85, 2018-03-15
@lvv85

You can use the FileSystemWatcher class to watch for changes to a folder.

A
Alexander Simonov, 2018-03-15
@SimasikS

Well, the first thing that comes to mind is to use git
. You just run git commands somewhere in your program
. For example, you need to make a backup in the program and you do something like

ProcessStartInfo psi;
psi = new ProcessStartInfo("cmd", $"git commit -a -m { backup_name }");
Process.Start(psi);

It will be possible to view changes through diff
Through .gitignore, configure tracked files
In my opinion, a very sensible solution

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question