This project has moved and is read-only. For the latest updates, please go here.

Upload Photo Filesize was zero

Topics: Developer Forum
Mar 8, 2012 at 6:03 PM

Hello All,

I recently downloaded the and I am trying to Upload a Photo.

But no matter what I do, I always get the same error "Filesize was zero (4)"

Do you know what this means?


  , fileName, title, description, tags, isPublic, isFamily, isFriend, ContentType.Photo, SafetyLevel.Safe, HiddenFromSearch.Visible, p =>                {                    FlickrUploadArgs flickrUploadArgs = new FlickrUploadArgs();
                    flickrUploadArgs.flickrResult = p;
                    this.OnUploadCompleted(flickrUploadArgs);                });

Mar 8, 2012 at 6:53 PM

How are you creating your stream object?


Mar 8, 2012 at 6:57 PM

I collect the Images using the PictureCollection from the XNA framework, then I get the stream using the Method GetImage from the Picture Class.

Thanks for the fast reply

Mar 8, 2012 at 6:59 PM

Is this in WP7?

Mar 8, 2012 at 7:01 PM

Yes, It is.

Mar 8, 2012 at 7:44 PM

I changed the ConvertNonSeekableStreamToByteArray method and It appears to work.

Now I am getting another problem. Filetype was not recognised



Mar 26, 2012 at 12:39 PM

Did you ever get anywhere with this? I've never had any problem with uploads in WP7, but I've always been working directly with the camera task to get my images.

Perhaps if you could provide a bit more code around how you obtain the stream specific to the XNA framework PictureCollection I might be able to reproduce the problem.

Mar 26, 2012 at 12:43 PM

Thanks fine by now....

I fixed the problem here it worked fine.

Probably I did something wrong that I cant even remember now.

Thanks for the reply.

Everything is working fine. Good work :) 

Apr 4, 2012 at 9:37 AM

hello, do you still remember how to fix this problem? I have the same problem.

I get the stream like this:

private void photoChooser_Completed(object sender, PhotoResult e)
                if (e.TaskResult == TaskResult.OK)
                    BitmapImage bitmap = new BitmapImage();
                    this.UploadImage.Source = bitmap;

                      //this is the stream.
                       uploadSelectViewModel.Stream = e.ChosenPhoto;
            catch (Exception a)


Apr 4, 2012 at 9:43 AM

It is likely that using the stream to create the bitmap has moved the stream to the end.

If the stream that ChosenPhoto returns is seekable you could try setting e.ChosePhoto.Position = 0 before adding it to the view model (or even better reset this when you do the upload).

Apr 4, 2012 at 10:06 AM

I appricate for you support, yes, you are right, I remove this, it works fine, but I need it show it the phone when picture is selected.

Could you please explain to me how to reset it?  in the property of e.ChosePhoto don't has Position.

 //BitmapImage bitmap = new BitmapImage();
                    //this.UploadImage.Source = bitmap;

Apr 4, 2012 at 10:19 AM

e.ChosenPhoto is a Stream class. Stream.Position is a standard property of that class.

Apr 4, 2012 at 11:40 AM

You are great!It works fine.many thanks.