我正在尝试用 C# 为 Windows Phone 开发一个应用程序,它基本上将用户选择的图片上传到服务器(例如本地主机)。这个应用程序旨在像 PHP 文件上传脚本一样工作,用户选择一个文件,然后将其上传到服务器上所需的目录。
我已经编写了在图片选择器任务的帮助下选择图片的代码。但是,现在我完全糊涂了。我只是不知道如何处理选定的图片。
这是要求用户选择图片的页面的代码:
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 Microsoft.Phone.Controls;
using Microsoft.Phone.Tasks;
using System.IO;
using System.Windows.Media.Imaging;
namespace QR_Reader
{
public partial class SamplePage : PhoneApplicationPage
{
public SamplePage()
{
InitializeComponent();
}
PhotoChooserTask selectphoto = null;
private void SampleBtn_Click(object sender, RoutedEventArgs e)
{
selectphoto = new PhotoChooserTask();
selectphoto.Completed += new EventHandler<PhotoResult>(selectphoto_Completed);
selectphoto.Show();
}
void selectphoto_Completed(object sender, PhotoResult e)
{
if (e.TaskResult == TaskResult.OK)
{
BinaryReader reader = new BinaryReader(e.ChosenPhoto);
image1.Source = new BitmapImage(new Uri(e.OriginalFileName));
txtBX.Text = e.OriginalFileName;
}
}
}
}
请帮我。
这里,txtBX 是一个文本框,用于显示所选图片的路径。