예제 #1
0
        public void OnListDirectorys(string name)
        {
            StringSequence strings = new StringSequence();

            if (Directory.Exists(BaseDir + _currentDirectory))
            {
                try
                {
                    string[] dirs = Directory.GetDirectories(BaseDir + _currentDirectory + "/" + name);
                    LogService.Info(this, "List folders under {0} success", name);

                    for (int i = 0; i < dirs.Length; i++)
                    {
                        strings.GetElements().AddRange(dirs);
                    }

                    _connection.Send(FileServerHelper.ListDirectorysResult(0, strings));
                    return;
                }
                catch (Exception err)
                {
                    LogService.ErrorE(this, string.Format("failed to list directory {0} under {1}", name, _currentDirectory), err);

                    strings.Add(err.Message);
                    _connection.Send(FileServerHelper.ListDirectorysResult(-1, strings));
                }
            }
            else
            {
                LogService.Warn(this, "Directory {0} does not exist", name);
                _connection.Send(FileServerHelper.ListDirectorysResult(-2, strings));
            }
        }