示例#1
0
        public static void HandleDirectoryResponse(Client client, DirectoryResponse packet)
        {
            if (client.Value.FrmFm == null)
                return;

            client.Value.FrmFm.ClearFileBrowser();

            new Thread(() =>
            {
                ListViewItem lviBack = new ListViewItem(new string[] { "..", "", "Directory" })
                {
                    Tag = "dir",
                    ImageIndex = 0
                };

                client.Value.FrmFm.AddItemToFileBrowser(lviBack);

                if (packet.Folders != null && packet.Folders.Length != 0)
                {
                    for (int i = 0; i < packet.Folders.Length; i++)
                    {
                        if (packet.Folders[i] != DELIMITER)
                        {
                            ListViewItem lvi = new ListViewItem(new string[] { packet.Folders[i], "", "Directory" })
                            {
                                Tag = "dir",
                                ImageIndex = 1
                            };

                            if (client.Value.FrmFm == null)
                                break;

                            client.Value.FrmFm.AddItemToFileBrowser(lvi);
                        }
                    }
                }

                if (packet.Files != null && packet.Files.Length != 0)
                {
                    for (int i = 0; i < packet.Files.Length; i++)
                    {
                        if (packet.Files[i] != DELIMITER)
                        {
                            ListViewItem lvi =
                                new ListViewItem(new string[] { packet.Files[i], Helper.Helper.GetDataSize(packet.FilesSize[i]), "File" })
                                {
                                    Tag = "file",
                                    ImageIndex = Helper.Helper.GetFileIcon(Path.GetExtension(packet.Files[i]))
                                };

                            if (client.Value.FrmFm == null)
                                break;

                            client.Value.FrmFm.AddItemToFileBrowser(lvi);
                        }
                    }
                }

                client.Value.LastDirectorySeen = true;
            }).Start();
        }
示例#2
0
        public static void HandleDirectoryResponse(Client client, DirectoryResponse packet)
        {
            if (client.Value.FrmFm == null)
                return;

            client.Value.FrmFm.Invoke((MethodInvoker) delegate { client.Value.FrmFm.lstDirectory.Items.Clear(); });

            new Thread(() =>
            {
                ListViewItem lviBack = new ListViewItem(new string[] {"..", "", "Directory"})
                {
                    Tag = "dir",
                    ImageIndex = 0
                };

                client.Value.FrmFm.Invoke(
                    (MethodInvoker) delegate { client.Value.FrmFm.lstDirectory.Items.Add(lviBack); });

                if (packet.Folders.Length != 0)
                {
                    for (int i = 0; i < packet.Folders.Length; i++)
                    {
                        if (packet.Folders[i] != DELIMITER)
                        {
                            ListViewItem lvi = new ListViewItem(new string[] {packet.Folders[i], "", "Directory"})
                            {
                                Tag = "dir",
                                ImageIndex = 1
                            };

                            try
                            {
                                client.Value.FrmFm.Invoke(
                                    (MethodInvoker) delegate { client.Value.FrmFm.lstDirectory.Items.Add(lvi); });
                            }
                            catch
                            {
                                break;
                            }
                        }
                    }
                }

                if (packet.Files.Length != 0)
                {
                    for (int i = 0; i < packet.Files.Length; i++)
                    {
                        if (packet.Files[i] != DELIMITER)
                        {
                            ListViewItem lvi =
                                new ListViewItem(new string[]
                                {packet.Files[i], Helper.Helper.GetFileSize(packet.FilesSize[i]), "File"})
                                {
                                    Tag = "file",
                                    ImageIndex = Helper.Helper.GetFileIcon(Path.GetExtension(packet.Files[i]))
                                };

                            try
                            {
                                client.Value.FrmFm.Invoke(
                                    (MethodInvoker) delegate { client.Value.FrmFm.lstDirectory.Items.Add(lvi); });
                            }
                            catch
                            {
                                break;
                            }
                        }
                    }
                }

                client.Value.LastDirectorySeen = true;
            }).Start();
        }