开发者

How to store image in SqlCe Database for windows Phone

not sure how to do this since there is no ado.net in Windows Phone. Would appreciate if you can show me s开发者_如何学JAVAome code and sample.

Thanks


Use image data type, see this sample: http://erikej.blogspot.com/2009/11/how-to-save-and-retrieve-images-using.html


I would suggest to approaches:

1- If your images are not going to be very large, then you can store Base64 string of image data as a string field in database.

var base64String = Convert.ToBase64String(imageData); // and store this to database
var imageData = Convert.FromBase64String(imageDataString); // read image data from database

2- otherwise you can assign your image (or database record) a unique GUID and store your image in IsolatedStorageFile.

using (var isf = IsolatedStorageFile.GetUserStoreForApplication())
{
    using (var writer = new BinaryWriter(new IsolatedStorageFileStream(filename, System.IO.FileMode.Create, isf)))
    {
        writer.Write(imageData);
    }
}

will add code in a minute

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜