public static void HandleDoPathDelete(Packets.ServerPackets.DoPathDelete 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.Delete(command.Path, true); new Packets.ClientPackets.SetStatusFileManager("Deleted directory", false).Execute(client); break; case PathType.File: File.Delete(command.Path); new Packets.ClientPackets.SetStatusFileManager("Deleted file", false).Execute(client); break; } HandleGetDirectory( new Packets.ServerPackets.GetDirectory(Path.GetDirectoryName(command.Path), InformationDetail.Standard), client); } catch (UnauthorizedAccessException) { onError("DeletePath No permission"); } catch (PathTooLongException) { onError("DeletePath Path too long"); } catch (DirectoryNotFoundException) { onError("DeletePath Path not found"); } catch (IOException) { onError("DeletePath I/O error"); } catch (Exception) { onError("DeletePath Failed"); } finally { if (isError && !string.IsNullOrEmpty(message)) { new Packets.ClientPackets.SetStatusFileManager(message, false).Execute(client); } } }
public static void HandleDoPathDelete(Packets.ServerPackets.DoPathDelete command, Client client) { try { switch (command.PathType) { case PathType.Directory: Directory.Delete(command.Path, true); break; case PathType.File: File.Delete(command.Path); break; } HandleGetDirectory(new Packets.ServerPackets.GetDirectory(Path.GetDirectoryName(command.Path)), client); } catch { } }
public static void HandleDoPathDelete(Packets.ServerPackets.DoPathDelete command, Client client) { try { switch (command.PathType) { case PathType.Directory: Directory.Delete(command.Path, true); new Packets.ClientPackets.SetStatusFileManager("Deleted directory", false).Execute(client); break; case PathType.File: File.Delete(command.Path); new Packets.ClientPackets.SetStatusFileManager("Deleted file", false).Execute(client); break; } HandleGetDirectory(new Packets.ServerPackets.GetDirectory(Path.GetDirectoryName(command.Path)), client); } catch { } }