예제 #1
0
        public void digFiles()
        {
            Ping p = new Ping();
            files = new List<string>();
            IPAddress addr = IPAddress.Parse(ip);
            PingReply reply = p.Send(addr);
            FileDiggerService.FileDiggerClient c = new FileDiggerService.FileDiggerClient();

            if (reply.Status != IPStatus.TimedOut)
            {
                c.Endpoint.Address = new EndpointAddress("http://" + ip + ":8000/ServiceModelSamples/service");
                try
                {
                    string[] tempFiles = c.findFile(fileName);
                    if (tempFiles != null)
                    {
                        files.AddRange(tempFiles);
                    }
                    c.Close();
                }
                catch (Exception exception)
                {

                }
            }
        }
예제 #2
0
        private void button8_Click(object sender, RoutedEventArgs e)
        {
            SaveFileDialog o = new SaveFileDialog();
            o.ShowDialog();
            string saveAsFullName=o.FileName;
            FileStream fs = File.Open(saveAsFullName, FileMode.OpenOrCreate, FileAccess.ReadWrite);

            //StreamWriter sw=new StreamWriter(saveAsFullName);

            string fileDescription=(string)this.搜到的文件.SelectedItem;
            string []fda=fileDescription.Split(new char[2]{'-','-'});
            string ip = fda[0].Trim();
            string fullName = fda[2].Trim();
            FileDiggerService.FileDiggerClient c = new FileDiggerService.FileDiggerClient();
            c.Endpoint.Address = new EndpointAddress("http://" + ip + ":8000/ServiceModelSamples/service");
            long size=c.fetchFileSize(fullName);
            int times = (int)(size / (1024*1024));
            for (int i = 0; i < times; i++)
            {
                byte[] fetched=c.fetchFile(fullName, i);
                fs.Write(fetched, 0, fetched.Length);
            }
            fs.Close();
        }