如何上传wp 7服务器端的图片。

时间:2012-05-31 11:18:40

标签: windows-phone-7 image-uploading

你好我有IsolatedStorageFile,这个文件是图像所以我想将这个图像上传到服务器端以便使用Avatar,这样我就可以上传我的图像字节[]。

我的代码就像这样。

 using (IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication())
            {
                // Open the file - error handling omitted for brevity
                // Note: If the image does not exist in isolated storage the following exception will be generated:
                // System.IO.IsolatedStorage.IsolatedStorageException was unhandled 
                // Message=Operation not permitted on IsolatedStorageFileStream 
                using (IsolatedStorageFileStream isfs = isf.OpenFile("myImage.jpg", FileMode.Open, FileAccess.Read))
                {
                    // Allocate an array large enough for the entire file
                    data = new byte[isfs.Length];
                    // Read the entire file and then close it
                    isfs.Read(data, 0, data.Length);
                    isfs.Close();
                }
            }

            // Create memory stream and bitmap
            MemoryStream ms = new MemoryStream(data);
            BitmapImage bi = new BitmapImage();
            // Set bitmap source to memory stream
            bi.SetSource(ms);

如何将此byte []上传到webClient或HttpwebRequest。?

谢谢。!

1 个答案:

答案 0 :(得分:0)

您是否查看过以下链接:File Upload。这应该有用。