1

你好我有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);

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

谢谢。!

4

1 回答 1

0

您是否查看了以下链接:文件上传。这应该有效。

于 2012-05-31T11:30:17.197 回答