예제 #1
0
        void Delete(ISync local, SyncFolder lfolder, string filterFolder, string filterFile)
        {
            if (lfolder == null)
            {
                return;
            }

            // Folder
            foreach (SyncFolder f in lfolder.Folders)
            {
                if (!StringHelper.Like(filterFolder, f.Name))
                {
                    continue;
                }

                if (f.Checked)
                {
                    // Esta, hacerlo recursivo
                    Delete(local, f, filterFolder, filterFile);
                }
                else
                {
                    try
                    {
                        local.DeleteFolder(f);
                        WriteInfo("Deleting folder: " + f.GetFullPath('/'));
                    }
                    catch (Exception e)
                    {
                        WriteError(e.Message);
                    }
                }
            }

            // Files
            foreach (SyncFile f in lfolder.Files)
            {
                if (f.Checked || !StringHelper.Like(filterFile, f.Name))
                {
                    continue;
                }

                try
                {
                    local.DeleteFile(f);
                    WriteInfo("Deleting file: " + f.GetFullPath('/'));
                }
                catch (Exception e)
                {
                    WriteError(e.Message);
                }
            }
        }