microkarl
Regular
All,
I am learning C#, so I want to create some simple program and learn it this way. The simple program that I am thinking is a backup/sync utility. However, there's a performance issue in my mind. If I have selected two folders: A, which is the target folder; and B, which is the destination folder. And both of them has some files that the other one does NOT have. Now, the way that I am implementing is as follow:
1: Compare folder A's files against B's file - (this means I am running a foreach statements on folder A now!!)
1.1: if A have files that are more updated, copy them into folder B; likewise, if B have more updated files, copy them into A. Moreover, put their names into an array.
1.2: if A have files that B does not have, copy them into folder B. Moreover, put their names into an array list.
2: Compare folder B's files against A's file - (this means I am running a foreach statements on folder B now!!)
2.1: Within the foreach statment, check B's files to see if their name are on the arraylist,
- if yes, this means they have been compared in 1.1 or they are added into B's folder recently in step 1.2.
- if no, this means B have some files A does not have. then copy them over to A.
This is the best way I can think of, what do you guys think? The main reason I don't like this approach is the two foreach statments and inside every loop of the foreach statment, it has to find the file from the other folder first... so I don't think this is effecient. Just imagine if you have couple hundred files in each folders.
And, yes, if you are thinking what the heck should I go through all these troubles while all I need to do is to make a .BAT files and do a XCOPY... well, it's because this is a good way for me to learn not only programming, but designing... so please gimme some hints.
Thanks,
Carl
I am learning C#, so I want to create some simple program and learn it this way. The simple program that I am thinking is a backup/sync utility. However, there's a performance issue in my mind. If I have selected two folders: A, which is the target folder; and B, which is the destination folder. And both of them has some files that the other one does NOT have. Now, the way that I am implementing is as follow:
1: Compare folder A's files against B's file - (this means I am running a foreach statements on folder A now!!)
1.1: if A have files that are more updated, copy them into folder B; likewise, if B have more updated files, copy them into A. Moreover, put their names into an array.
1.2: if A have files that B does not have, copy them into folder B. Moreover, put their names into an array list.
2: Compare folder B's files against A's file - (this means I am running a foreach statements on folder B now!!)
2.1: Within the foreach statment, check B's files to see if their name are on the arraylist,
- if yes, this means they have been compared in 1.1 or they are added into B's folder recently in step 1.2.
- if no, this means B have some files A does not have. then copy them over to A.
This is the best way I can think of, what do you guys think? The main reason I don't like this approach is the two foreach statments and inside every loop of the foreach statment, it has to find the file from the other folder first... so I don't think this is effecient. Just imagine if you have couple hundred files in each folders.
And, yes, if you are thinking what the heck should I go through all these troubles while all I need to do is to make a .BAT files and do a XCOPY... well, it's because this is a good way for me to learn not only programming, but designing... so please gimme some hints.
Thanks,
Carl