private void ThreadFunUpload_Directory(object obj)
        {
            StructByte     S_B = new StructByte();
            SockInfo_U     s   = (SockInfo_U)obj;
            Directory_info d   = new Directory_info();
            List <string>  l   = new List <string>();

            d.name = s.di.Name;
            GetAllDirList(s.di.FullName, l, d);
            byte[] bu = new byte[270];
            string Root_directory_name = s.di.FullName.Substring(s.di.FullName.LastIndexOf(@"\") + 1);

            bu = S_B.StructToBytes(new info(Root_directory_name, (UInt32)d.size, 2, (UInt32)l.Count));
            s.s.Send(bu, bu.Length, SocketFlags.None);
            Thread.Sleep(1000);
            s.s.Receive(bu, SocketFlags.None);
            int i = BitConverter.ToInt32(bu, 0);

            Thread.Sleep(10);
            try
            {
                for (; i < l.Count; i++)
                {
                    string        name = l[i];
                    DirectoryInfo di   = new DirectoryInfo(name);
                    string        n    = name.Substring(name.IndexOf(Root_directory_name));
                    if (di.Attributes == FileAttributes.Directory)
                    {
                        bu = S_B.StructToBytes(new info(n, 0, 2, 1));
                        s.s.Send(bu, bu.Length, SocketFlags.None);
                    }
                    else if (di.Attributes == FileAttributes.Normal || di.Attributes == FileAttributes.Archive)
                    {
                        Upload_File(new FileStream((name), FileMode.Open, FileAccess.Read, FileShare.Read), s.s, n);
                    }
                }
                bu = S_B.StructToBytes(new info("asdf", 0, 0, 0));
                s.s.Send(bu, bu.Length, SocketFlags.None);
                s.s.Close();
            }
            catch (Exception)
            {
                ;
            }
            //  Console.WriteLine("asdf");
        }
        private List <string> GetAllDirList(string strBaseDir, List <string> list, Directory_info d)
        {
            DirectoryInfo di = new DirectoryInfo(strBaseDir);

            DirectoryInfo[] diA   = di.GetDirectories();
            FileInfo[]      files = di.GetFiles();
            foreach (var item in files)
            {
                d.size += item.Length;
                list.Add(item.FullName);
            }
            foreach (var item in diA)
            {
                list.Add(item.FullName);
                //diA[i].FullName是某个子目录的绝对地址,把它记录在ArrayList中
                GetAllDirList(item.FullName, list, d);
                //注意:递归了。逻辑思维正常的人应该能反应过来
            }
            return(list);
        }