예제 #1
0
파일: WinMain.cs 프로젝트: gezidan/ZYSOCKET
        private void _Up_Click(object sender, EventArgs e)
        {
            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                string filename = openFileDialog1.FileName;

               

                FileInfo file = new FileInfo(filename);

                if (file.Exists)
                {

                    FileStream stream = new FileStream(filename, FileMode.Open, FileAccess.Read);

                Re:
                    long key = DateTime.Now.Ticks;

                    if (UpFileList.ContainsKey(key))
                    {
                        System.Threading.Thread.Sleep(1);
                        goto Re;

                    }
                    UpFileList.Add(key, stream);



                    string upfilename = CurrentDir + file.Name;

                    if (CurrentDir[CurrentDir.Length - 1] != '\\')
                    {
                        upfilename = CurrentDir + "\\" + file.Name;
                    }

                    UpFile upfile = new UpFile()
                    {
                        FullName = upfilename,
                        Size = stream.Length,
                        UpKey = key,
                    };


                    SocketManager.Send(BufferFormatV2.FormatFCA(upfile, Deflate.Compress));
                }

            }
        }
예제 #2
0
파일: WinMain.cs 프로젝트: gezidan/ZYSOCKET
        private void listView1_DragDrop(object sender, DragEventArgs e)
        {
            if (e.Data.GetDataPresent(DataFormats.FileDrop))
            {
                string str = ((System.Array)e.Data.GetData(DataFormats.FileDrop)).GetValue(0).ToString();


                FileInfo file = new FileInfo(str);

                if (file.Exists)
                {

                    FileStream stream = new FileStream(str, FileMode.Open, FileAccess.Read);

                Re:
                    long key = DateTime.Now.Ticks;

                    if (UpFileList.ContainsKey(key))
                    {
                        System.Threading.Thread.Sleep(1);
                        goto Re;

                    }
                    UpFileList.Add(key, stream);



                    string upfilename = CurrentDir + file.Name;

                    if (CurrentDir[CurrentDir.Length - 1] != '\\')
                    {
                        upfilename = CurrentDir + "\\" + file.Name;
                    }

                    UpFile upfile = new UpFile()
                    {
                        FullName = upfilename,
                        Size = stream.Length,
                        UpKey = key,
                    };


                    SocketManager.Send(BufferFormatV2.FormatFCA(upfile, Deflate.Compress));
                }


            }

            else if (e.Data.GetDataPresent(DataFormats.Text))
            {
                MessageBox.Show((e.Data.GetData(DataFormats.Text)).ToString(), "提示信息", MessageBoxButtons.OK); 
            }
        }
예제 #3
0
파일: WinMain.cs 프로젝트: gezidan/ZYSOCKET
        private void UpFileEx(string cudir,string name)
        {


            FileInfo file = new FileInfo(name);

            if (file.Exists)
            {

                FileStream stream = new FileStream(name, FileMode.Open, FileAccess.Read);

            Re:
                long key = DateTime.Now.Ticks;

                if (UpFileList.ContainsKey(key))
                {
                    System.Threading.Thread.Sleep(1);
                    goto Re;

                }
                UpFileList.Add(key, stream);

                string upfilename = System.IO.Path.Combine(cudir,file.Name);

                UpFile upfile = new UpFile()
                {
                    FullName = upfilename,
                    Size = stream.Length,
                    UpKey = key,
                };


                SocketManager.Send(BufferFormatV2.FormatFCA(upfile, Deflate.Compress));
            }
            else
            {
                DirectoryInfo dir = new DirectoryInfo(name);

                if (dir.Exists)
                {
                    string fullname =System.IO.Path.Combine(cudir,dir.Name);              


                    PackHandler.NewDir ndir = new PackHandler.NewDir()
                    {
                        DirName = fullname
                    };

                    SocketManager.Send(BufferFormatV2.FormatFCA(ndir, Deflate.Compress));


                    foreach (var item in dir.GetFileSystemInfos())
                    {
                        UpFileEx(fullname, item.FullName);
                    }
                }

            }
        }