WEB开发网
开发学院图形图像Flash Silverlight专题(10)-WCF通信(2) 阅读

Silverlight专题(10)-WCF通信(2)

 2008-10-27 11:49:08 来源:WEB开发网   
核心提示: a.选择上传文件对话框的实现如下1 public void uploadBtn_Click(object sender, RoutedEventArgs e)2 {3 OpenFileDialog ofd = new OpenFileDialog();4 ofd.Filter = &quo

a.选择上传文件对话框的实现如下

1 public void uploadBtn_Click(object sender, RoutedEventArgs e)
2 {
3   OpenFileDialog ofd = new OpenFileDialog();
4   ofd.Filter = "JPG Files|*.jpg|PNG Files|*.png";
5   ofd.Multiselect = false;
6 
7   if ((bool)ofd.ShowDialog())
8   {
9     this.pb.Visibility = Visibility.Visible;
10     this.img.Opacity = 0;
11     dataSent = 0;
12     stream = ofd.File.OpenRead();
13     dataLength = stream.Length;
14     if (dataLength > 16384)
15     {
16       firstChunk = true;
17       lastChunk = false;
18       fileName = ofd.File.Name;
19       byte[] buffer = new byte[4 * 4096];
20       int read = stream.Read(buffer, 0, buffer.Length);
21       dataSent += read;
22       if (read != 0)
23       {
24         if (dataSent == dataLength)
25           lastChunk = true;
26         client.UploadImgAsync(fileName, buffer, firstChunk, lastChunk);
27         firstChunk = false;
28       }
29     }
30 
31     else
32     {
33       MessageBox.Show("The upload file is too small!");
34     }
35   }
36 }

上一页  1 2 3 4  下一页

Tags:Silverlight 专题 WCF

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接