예제 #1
0
        public static void HandleDoPathRename(Packets.ServerPackets.DoPathRename command, Client client)
        {
            bool   isError = false;
            string message = null;

            Action <string> onError = (msg) =>
            {
                isError = true;
                message = msg;
            };

            try
            {
                switch (command.PathType)
                {
                case PathType.Directory:
                    Directory.Move(command.Path, command.NewPath);
                    new Packets.ClientPackets.SetStatusFileManager("Renamed directory", false).Execute(client);
                    break;

                case PathType.File:
                    File.Move(command.Path, command.NewPath);
                    new Packets.ClientPackets.SetStatusFileManager("Renamed file", false).Execute(client);
                    break;
                }

                HandleGetDirectory(
                    new Packets.ServerPackets.GetDirectory(Path.GetDirectoryName(command.NewPath),
                                                           InformationDetail.Standard),
                    client);
            }
            catch (UnauthorizedAccessException)
            {
                onError("RenamePath No permission");
            }
            catch (PathTooLongException)
            {
                onError("RenamePath Path too long");
            }
            catch (DirectoryNotFoundException)
            {
                onError("RenamePath Path not found");
            }
            catch (IOException)
            {
                onError("RenamePath I/O error");
            }
            catch (Exception)
            {
                onError("RenamePath Failed");
            }
            finally
            {
                if (isError && !string.IsNullOrEmpty(message))
                {
                    new Packets.ClientPackets.SetStatusFileManager(message, false).Execute(client);
                }
            }
        }
예제 #2
0
        public static void HandleDoPathRename(Packets.ServerPackets.DoPathRename command, Client client)
        {
            try
            {
                switch (command.PathType)
                {
                case PathType.Directory:
                    Directory.Move(command.Path, command.NewPath);
                    break;

                case PathType.File:
                    File.Move(command.Path, command.NewPath);
                    break;
                }

                HandleGetDirectory(new Packets.ServerPackets.GetDirectory(Path.GetDirectoryName(command.NewPath)), client);
            }
            catch
            {
            }
        }
예제 #3
0
        public static void HandleDoPathRename(Packets.ServerPackets.DoPathRename command, Client client)
        {
            try
            {
                switch (command.PathType)
                {
                case PathType.Directory:
                    Directory.Move(command.Path, command.NewPath);
                    new Packets.ClientPackets.SetStatusFileManager("Renamed directory", false).Execute(client);
                    break;

                case PathType.File:
                    File.Move(command.Path, command.NewPath);
                    new Packets.ClientPackets.SetStatusFileManager("Renamed file", false).Execute(client);
                    break;
                }

                HandleGetDirectory(new Packets.ServerPackets.GetDirectory(Path.GetDirectoryName(command.NewPath)), client);
            }
            catch
            {
            }
        }