稳扎稳打Silverlight(20) - 2.0通信之WebClient, 以字符串的形式上传/下载数据, 以流的方式上传/下载数据
2008-12-08 08:52
676 查看
[索引页]
[源码下载]
[align=center]稳扎稳打Silverlight(20) - 2.0通信之WebClient, 以字符串的形式上传/下载数据, 以流的方式上传/下载数据[/align]
作者:webabcd
介绍
Silverlight 2.0 详解WebClient,以字符串的形式上传、下载数据;以流的方式上传、下载数据
WebClient - 将数据发送到指定的 URI,或者从指定的 URI 接收数据的类
DownloadStringAsync(Uri address, Object userToken) - 以字符串的形式下载指定的 URI 的资源
UploadStringAsync(Uri address, string data) - 以字符串的形式上传数据到指定的 URI。所使用的 HTTP 方法默认为 POST
OpenReadAsync(Uri address, Object userToken) - 以流的形式下载指定的 URI 的资源
OpenWriteAsync(Uri address, string method, Object userToken) - 打开流以使用指定的方法向指定的 URI 写入数据
在线DEMO
/article/4589581.html
示例
1、以字符串的形式和流的形式下载数据
WebClientDownload.xaml
<UserControl x:Class="Silverlight20.Communication.WebClientDownload"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<StackPanel HorizontalAlignment="Left" Orientation="Horizontal">
<StackPanel Margin="5" Width="200">
<TextBox x:Name="lblMsgString" Margin="5" />
<ProgressBar x:Name="progressBarString" Height="20" Margin="5" Minimum="0" Maximum="100" />
</StackPanel>
<StackPanel Margin="5" Width="200">
<TextBox x:Name="lblMsgStream" Margin="5" />
<ProgressBar x:Name="progressBarStream" Height="20" Margin="5" Minimum="0" Maximum="100" />
<Image x:Name="img" Margin="5" />
</StackPanel>
</StackPanel>
</UserControl>
WebClientDownload.xaml.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.IO;
namespace Silverlight20.Communication
using System;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Activation;
using System.ServiceModel.Web;
using System.Collections.Generic;
using System.Text;
using System.IO;
[ServiceContract]
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
public class REST
WebClientUpload.xaml
<UserControl x:Class="Silverlight20.Communication.WebClientUpload"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<StackPanel HorizontalAlignment="Left" Orientation="Horizontal">
<StackPanel Margin="5" Width="200">
<TextBox x:Name="lblMsgString" Margin="5" />
<ProgressBar x:Name="progressBarString" Height="20" Margin="5" Minimum="0" Maximum="100" />
<Button x:Name="btnString" Content="上传文件(字符串的方式)" Margin="5" Click="btnString_Click" />
</StackPanel>
<StackPanel Margin="5" Width="200">
<TextBox x:Name="lblMsgStream" Margin="5" />
<ProgressBar x:Name="progressBarStream" Height="20" Margin="5" Minimum="0" Maximum="100" />
<Button x:Name="btnStream" Content="上传文件(流的方式)" Margin="5" Click="btnStream_Click" />
</StackPanel>
</StackPanel>
</UserControl>
WebClientUpload.xaml.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.IO;
using System.Windows.Resources;
using System.ComponentModel;
using System.Windows.Browser;
namespace Silverlight20.Communication
OK
[源码下载]
[源码下载]
[align=center]稳扎稳打Silverlight(20) - 2.0通信之WebClient, 以字符串的形式上传/下载数据, 以流的方式上传/下载数据[/align]
作者:webabcd
介绍
Silverlight 2.0 详解WebClient,以字符串的形式上传、下载数据;以流的方式上传、下载数据
WebClient - 将数据发送到指定的 URI,或者从指定的 URI 接收数据的类
DownloadStringAsync(Uri address, Object userToken) - 以字符串的形式下载指定的 URI 的资源
UploadStringAsync(Uri address, string data) - 以字符串的形式上传数据到指定的 URI。所使用的 HTTP 方法默认为 POST
OpenReadAsync(Uri address, Object userToken) - 以流的形式下载指定的 URI 的资源
OpenWriteAsync(Uri address, string method, Object userToken) - 打开流以使用指定的方法向指定的 URI 写入数据
在线DEMO
/article/4589581.html
示例
1、以字符串的形式和流的形式下载数据
WebClientDownload.xaml
<UserControl x:Class="Silverlight20.Communication.WebClientDownload"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<StackPanel HorizontalAlignment="Left" Orientation="Horizontal">
<StackPanel Margin="5" Width="200">
<TextBox x:Name="lblMsgString" Margin="5" />
<ProgressBar x:Name="progressBarString" Height="20" Margin="5" Minimum="0" Maximum="100" />
</StackPanel>
<StackPanel Margin="5" Width="200">
<TextBox x:Name="lblMsgStream" Margin="5" />
<ProgressBar x:Name="progressBarStream" Height="20" Margin="5" Minimum="0" Maximum="100" />
<Image x:Name="img" Margin="5" />
</StackPanel>
</StackPanel>
</UserControl>
WebClientDownload.xaml.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.IO;
namespace Silverlight20.Communication
using System;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Activation;
using System.ServiceModel.Web;
using System.Collections.Generic;
using System.Text;
using System.IO;
[ServiceContract]
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
public class REST
WebClientUpload.xaml
<UserControl x:Class="Silverlight20.Communication.WebClientUpload"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<StackPanel HorizontalAlignment="Left" Orientation="Horizontal">
<StackPanel Margin="5" Width="200">
<TextBox x:Name="lblMsgString" Margin="5" />
<ProgressBar x:Name="progressBarString" Height="20" Margin="5" Minimum="0" Maximum="100" />
<Button x:Name="btnString" Content="上传文件(字符串的方式)" Margin="5" Click="btnString_Click" />
</StackPanel>
<StackPanel Margin="5" Width="200">
<TextBox x:Name="lblMsgStream" Margin="5" />
<ProgressBar x:Name="progressBarStream" Height="20" Margin="5" Minimum="0" Maximum="100" />
<Button x:Name="btnStream" Content="上传文件(流的方式)" Margin="5" Click="btnStream_Click" />
</StackPanel>
</StackPanel>
</UserControl>
WebClientUpload.xaml.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.IO;
using System.Windows.Resources;
using System.ComponentModel;
using System.Windows.Browser;
namespace Silverlight20.Communication
OK
[源码下载]
相关文章推荐
- 稳扎稳打Silverlight(20) - 2.0通信之WebClient, 以字符串的形式上传/下载数据, 以流的方式上传/下载数据
- 稳扎稳打Silverlight(20) - 2.0通信之WebClient, 以字符串的形式上传/下载数据, 以流的方式上传/下载数据
- 上接稳扎稳打Silverlight(20) - 2.0通信之WebClient, 以字符串的形式上传/下载数据
- 2.0通信之WebClient, 以字符串的形式上传/下载数据, 以流的方式上传/下载数据
- WebClient, 以字符串的形式上传/下载数据, 以流的方式上传/下载数据(转)
- 稳扎稳打Silverlight(28) - 2.0通信之调用ADO.NET Data Services(数据服务)
- 稳扎稳打Silverlight(19) - 2.0通信之调用REST服务,处理JSON格式, XML格式, RSS/ATOM格式的数据
- (12):Silverlight 2 数据与通信之WebClient
- SilverLight学习笔记--使用WebClient实现通讯(一)(上传和下载字符串数据)
- 稳扎稳打Silverlight(28) - 2.0通信之调用ADO.NET Data Services(数据服务)
- 一步一步学Silverlight 2系列(12):数据与通信之WebClient
- SilverLight学习笔记--使用WebClient实现通讯(一)(上传和下载字符串数据)
- 一步一步学Silverlight 2系列(12):数据与通信之WebClient
- 稳扎稳打Silverlight(19) - 2.0通信之调用REST服务,处理JSON格式, XML格式, RSS/ATOM格式的数据
- 一步一步学Silverlight 2系列(12):数据与通信之WebClient
- 稳扎稳打Silverlight(21) - 2.0通信之WebRequest和WebResponse, 对指定的URI发出请求以及接收响应
- 一步一步学Silverlight 2系列(12):数据与通信之WebClient
- 稳扎稳打Silverlight(21) - 2.0通信之WebRequest和WebResponse, 对指定的URI发出请求以及接收响应
- 一步一步学Silverlight 2系列(12):数据与通信之WebClient
- Silverlight 2系列(12):数据与通信之WebClient