如何在Windows Phone 7中使用webclient上传视频

时间:2012-07-11 05:28:06

标签: windows-phone-7

我正在尝试使用webclient上传视频,但我无法这样做 这是我的代码

private void UploadFile(string fileName)
{
    Stream data = Application.GetResourceStream(new Uri(@"DemoProject;component/test.mp4", UriKind.Relative)).Stream;

    UriBuilder ub = new UriBuilder("http://www.abc.com/xyz/");
    ub.Query = string.Format("name={0}", fileName);

    WebClient c = new WebClient();
    c.OpenWriteCompleted += (sender, e) =>
    {
        PushData(data, e.Result);
        e.Result.Close();
        data.Close();
    };
    c.OpenWriteAsync(ub.Uri);
}

private void PushData(Stream input, Stream output)
{
    byte[] buffer = new byte[4096];
    int bytesRead;

    while ((bytesRead = input.Read(buffer, 0, buffer.Length)) != 0)
    {
        output.Write(buffer, 0, bytesRead);
    }
}

plz建议如何上传

1 个答案:

答案 0 :(得分:0)

我发现答案我使用上面的代码只是传递了错误的网址..