ฉันรวมโปรแกรมอ่าน (this)EPUB Reader เข้ากับโปรเจ็กต์ของฉัน มันทำงานได้ดี & ฉันต้องการโหลดไฟล์จาก SDCard แทนพื้นที่เก็บข้อมูลแบบแยกของอุปกรณ์
หากต้องการเปิดไฟล์จากที่เก็บข้อมูลแยก เรามี IsolatedStorageFileStream
เช่นนี้
IsolatedStorageFileStream isfs;
using (IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication())
{
try
{
isfs = isf.OpenFile([Path to file], FileMode.Open);
}
catch
{
return;
}
}
ePubView.Source = isfs;
สำหรับไฟล์ใน SDcard ฉันลองแบบนี้
ExternalStorageDevice sdCard = (await ExternalStorage.GetExternalStorageDevicesAsync()).FirstOrDefault();
// If the SD card is present, get the route from the SD card.
if (sdCard != null)
{
ExternalStorageFile file = await sdCard.GetFileAsync(_sdFilePath);
// _sdFilePath is string that having file path of file in SDCard
// Create a stream for the route.
Stream file = await file.OpenForReadAsync();
// Read the route data.
ePubView.Source = file;
}
ที่นี่ฉันได้รับข้อยกเว้น System.IO.EndOfStreamException
หากคุณต้องการลอง.. นี่คือลิงก์ตัวอย่างโครงการของฉัน
คำถาม : ฉันจะให้ไฟล์ของฉันเป็นแหล่งควบคุม epubView ได้อย่างไร
นี่เป็นวิธีที่ถูกต้องหรือไม่กรุณาแนะนำเกี่ยวกับเรื่องนี้ด้วย.. ขอบคุณ