Ejemplo n.º 1
0
        //------------get all messages----------------------
        public string[] GetAll(String path)
        {
            string theWay = (AppDomain.CurrentDomain.BaseDirectory + path);
            String body   = "";

            //DirectoryInfo directory = new DirectoryInfo(theWay);
            FileInfo[] files = _fileHandler.GetFileInfo(theWay);
            //FileInfo[] files = directory.GetFiles("*.txt");
            if (files.Length == 0)
            {
                body = "No files are available";
                string[] firstResponse = { "text/plain", "200 Request sucess", body };
                return(firstResponse);
            }
            body = _fileHandler.GetAllMessages(files);

            /*int number = 1;
             * foreach(var item in files)
             * {
             *  body += number.ToString() + ". Message:\n" + File.ReadAllText(item.ToString()) + "\n";
             *  number++;
             * }*/


            string[] secondResponse = { "text/plain", "200 Request sucess", body };
            return(secondResponse);
        }