Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using Microsoft.VisualBasic.FileIO;
- using System.IO;
- namespace ReplaceIcon
- {
- public class Replacer
- {
- public void Replace(ThemeIcon current, ThemeIcon replacement)
- {
- foreach (var size in current.Sizes)
- {
- Recycle(current[size]); // move an icon to recycle bin (trash)
- foreach (var related in size.Related)
- {
- if (File.Exists(replacement[related]))
- {
- // TODO: if it's a symbol link make sure it will replace an icon, not the symbol link
- Copy(replacement[related], current[size]);
- break;
- }
- }
- }
- }
- public void Copy(string source, string destination)
- {
- if (File.Exists(source))
- File.Copy(source, destination);
- }
- public void Recycle(string icon)
- {
- if (File.Exists(icon))
- FileSystem.DeleteFile(icon, UIOption.OnlyErrorDialogs, RecycleOption.SendToRecycleBin);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement