Beispiel #1
0
        private void CleanFolder()
        {
            string path      = GetQueuePath();
            string pathrelay = GetRelayPath();
            string pathback  = GetBackupPath();

            if (Directory.Exists(path))
            {
                if (!Directory.Exists(pathrelay))
                {
                    Directory.CreateDirectory(pathrelay);
                }

                if (!Directory.Exists(pathback))
                {
                    Directory.CreateDirectory(pathback);
                }
                //clean relay files to backup
                string[] relays = Directory.GetFiles(pathrelay, "*.mcq");
                if (relays != null)
                {
                    foreach (string rely in relays)
                    {
                        string relyID   = Path.GetFileNameWithoutExtension(rely);
                        string backfile = SysUtil.PathFix(pathback + relyID + ".mcq");
                        SysUtil.MoveFile(rely, backfile);
                    }

                    //Netlog.InfoFormat("CleanFolder Buckup files: {0} ", relays.Length);
                }

                //clean folder items and move them to relay
                string[] messages = Directory.GetFiles(path, "*.mcq");
                if (messages != null)
                {
                    foreach (string message in messages)
                    {
                        string messageID = Path.GetFileNameWithoutExtension(message);
                        string newfile   = SysUtil.PathFix(pathrelay + messageID + ".mcq");
                        SysUtil.MoveFile(message, newfile);
                    }
                    //Netlog.InfoFormat("CleanFolder items files: {0} ", messages.Length);
                }
            }
        }