Page 1 of 1

Keep a backup of a file, and detect changes when opened

Posted: Fri Sep 23, 2011 12:39 am
by zachman61
For example:
If you save a file and then close the program then edit it with Notepad++ or another text editor then reload the program and i want to be able to detect it was modified from what it was when the program was closed

Also the file type is a .ini

Re: Keep a backup of a file, and detect changes when opened

Posted: Fri Sep 23, 2011 12:42 am
by mandai
You could either compare part of the file data, or you could compare the last date it was modified.

Re: Keep a backup of a file, and detect changes when opened

Posted: Fri Sep 23, 2011 12:44 am
by zachman61
Well how would i save it as a backup inside the program?
or a better method of saving the data would be suffice.

Re: Keep a backup of a file, and detect changes when opened

Posted: Fri Sep 23, 2011 12:55 am
by mandai
If it has to be within the program, you could append the data to a list of byte arrays.

Re: Keep a backup of a file, and detect changes when opened

Posted: Fri Sep 23, 2011 1:06 am
by zachman61
I'd like it to be either encrypted .ini file or hidden within the program.

Re: Keep a backup of a file, and detect changes when opened

Posted: Fri Sep 23, 2011 5:56 am
by MrAksel
You could also use the FileSystemWatcher to detect changes. To storee the data you could use a byte array as mandai said.

Re: Keep a backup of a file, and detect changes when opened

Posted: Fri Sep 23, 2011 7:28 pm
by zachman61
Would it be easier to use a hidden folder and read the data from the hidden folder?

Re: Keep a backup of a file, and detect changes when opened

Posted: Fri Sep 23, 2011 7:44 pm
by MrAksel
Well you would still need to store the data when you read it...