Mac
Mac

Reputation: 157

Uploading WAV files to Skydrive for Windows Phone 7

I have recently created an audio recorder for wp7. But users started giving feedback that there was no way to upload the recorded files skydrive. I searched and I got lot of samples but they contain only for text files and photos Sample Link. I don't know how to upload .wav files to skydrive. Can anybody provide me some samples for this? Thanks in advance for your help!

Upvotes: 0

Views: 845

Answers (1)

Oliver Hanappi
Oliver Hanappi

Reputation: 12346

There is no difference between text files, photos and so on. They are all just a bunch of bytes, which are interpreted differently. In the link posted above, there is the following code snippet:

private void btnSave_Click(object sender, EventArgs e)
{
    string fileName = this.fileName.Text.Trim();
    byte[] byteArray = Encoding.Unicode.GetBytes(this.fileContent.Text.Trim());
    MemoryStream fileStream = new MemoryStream(byteArray);

    LiveConnectClient uploadClient = new LiveConnectClient(App.Current.LiveSession);
    uploadClient.UploadCompleted += new EventHandler<LiveOperationCompletedEventArgs>(uploadClient_UploadCompleted);
    uploadClient.UploadAsync("me/skydrive", fileName, fileStream );
}

The first three lines are concerned with converting a string into a stream of bytes, which can be uploaded. In order to upload a wav file, you just need to alter this three lines to prepare a stream containing your wav data.

If your wav file is saved within the isolated storage, you can use IsolatedStorageFile.OpenFile to get the right stream.

Upvotes: 2

Related Questions