1
我有一個SQLite數據庫文件,我需要複製到將使用它的平臺,我有點東西。我已經看過如何從XML文件中讀取文本的示例,但我只需要獲取流並將其複製,但我找不到需要使用哪個類來完成此操作。從便攜式類庫複製文件到Windows 8 - SQLite數據庫
這是我到目前爲止有:
public async Task CopyDatabase()
{
var s = Assembly.Load(new AssemblyName("PhenotypesLibrary")).GetManifestResourceStream(DBPath.DBPathAsString());
////create a folder and file
var folder = ApplicationData.Current.LocalFolder;
var file = await folder.CreateFileAsync(DBPath.DBPathAsString());
using (IRandomAccessStream fileStream = await file.OpenAsync(FileAccessMode.ReadWrite))
{
using (IOutputStream outputStream = fileStream.GetOutputStreamAt(0))
{
using (StreamWriter writer = new StreamWriter(outputStream.AsStreamForWrite()))
{
await writer.//ummmmmmmmm
}
//using (DataWriter dataWriter = new DataWriter(outputStream))
//{
// var bytes =
// dataWriter.WriteBytes
//}
}
}
// the way I did it from a file that was put in the project folder, not in a PCL
//string path = DBPath.DBPathAsString();
//bool copy = false;
//try
//{
// StorageFile file = await ApplicationData.Current.LocalFolder.GetFileAsync(path);
//}
//catch
//{
// copy = true;
//}
//if (copy)
//{
// var file = await StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///" + path));
// await file.CopyAsync(ApplicationData.Current.LocalFolder);
//}
}