Windows Phone 8 and Isolated Storage Tools แม้ว่า Windows Phone 8 จะมีความสามารถในการเรียกใช้งาน Application Data Folder แต่ก็ยังให้ความสำคัญกับ Isolated Storage ซึ่งเป็นพื้นที่สำหรับจัดเก็บข้อมูลของ Application ที่ทำงานบน Windows Phone ข้อดีของ Isolated Storage คือทำงานระดับ Application โดยแต่ล่ะ Application จะมี Isolated Storage เป็นของตัวเอง และทำงานแยกกันอย่างสิ้นเชิง ไม่สามารถเรียกใช้งาน Isolated Storage ของ Application อื่น ๆ ได้ ทั้งนี้เพื่อความปลอดภัยในการใช้ Application จึงได้ถูกออกแบบไว้ให้มีสิทธิ์เฉพาะใน Isolated Storage ที่ตัวเองมีอยู่เท่านั้น
โครงสร้างของ
Isolated Storage ของ Application บน Windows Phone
สำหรับ Isolated Storage บน Windows Phone 8 จะทำหน้าที่เก็บข้อมูลหลัก ๆ อยู่ 3 ตัวคือ
- Settings (เป็นค่า Setting ต่าง ๆ ของโปรแกรม)
- Files and folders (เป็นไฟล์ต่าง ๆ ที่เกิดขึ้นจากโปรแกรม รวมทั้งไฟล์ที่ได้เกิดขึ้นหลังจากโปรแกรมทำงานไปแล้ว เช่น รูปภาพ หรืออื่น ๆ)
- Relational data (เป็นไฟล์ที่ทำหน้าที่จัดเก็บ Database ที่เกิดขึ้นบน LINQ to SQL)
การเรียกดู Isolated Storage บน Emulator
ในกรณีที่เขียนโปรแกรม Windows Phone บน Visual Studio และทดสอบการทำงานบน Emulator บางครั้งเราจำเป็นจะต้อง เรียกใช้งาน Isolated Storage ของ Application เพื่อดูไฟล์ หรือ ทดสอบการทำงานของ Application ที่เราเขียนนั้นว่าสามารถทำได้ตรงกับความต้องการหรือไม่ โดยมีวิธีง่าย ๆ ดังนี้
Windows Phone 8.
สำหรับ Tools ที่มาพร้อมกับ SDK ของ Windows Phone 8.0 และ 8.1 ที่จะช่วยในการจัดการกับ Isolated Storage มีชื่อว่า ISETool.exe จัดเก็บไว้ที่
Isolated Storage
C:\Program Files (x86)\Microsoft SDKs\Windows Phone\v8.1\Tools\IsolatedStorageExplorerTool
ถ้าเป็น Version อื่น ๆ อาจจะถูกจัดเก็บไว้ที่อื่น (เช่น v8.0)

ในการดูไฟล์ หรือ Copy ไฟล์ต่าง ๆ สามารถทำผ่าน Command Promt (DOS) ได้ดังนี้
ISETool.exe dir xd <Product GUID>
โดย <Product GUID> คือ รหัส ProductID ของ Application โดยสามารถดูได้ที่ไฟล์ WMAppManifest.xml อยู่ในโฟเดอร์ Properties

เปิดไฟล์ WMAppManifest.xml ด้วยโปรแกรม EditPlus

จะได้หมายเลข ProjectID ซึ่งให้เอาตัวนี้ไปใช้

เปิด Command Prompt (DOS)

พิมพ์คำสั่ง
C:\Program Files (x86)\Microsoft SDKs\Windows Phone\v8.1\Tools\IsolatedStorageExplorerTool
ISETool.exe dir xd 160bedc0-fd4b-431e-b602-b5350eb65903

พิมพ์คำสั่งบน Command Prompt ดังรูป โปรแกรมจะแสดง Files ที่อยู่ใน Isolated Storage
การ Copy ไฟล์จาก Isolated Storage มาเก็บไว้บนเครื่อง PC Desktop

พิมพ์คำสั่ง
ISETool.exe ts xd 160bedc0-fd4b-431e-b602-b5350eb65903 "C:\data"
โดยจะ Copy ไฟล์จาก Isolated Storage มาจัดเก็บไว้ใน C:\data

แสดงไฟล์จาก Isolated Storage

แสดงไฟล์จาก Isolated Storage
การ Copy ไฟล์จาก PC Desktop ไปไว้บน Isolated Storage

เป็นไฟล์ที่เก็บอยู่บน Computer ของเราจัดเก็บไว้ใน C:\img
พิมพ์คำสั่ง
ISETool.exe rs xd 160bedc0-fd4b-431e-b602-b5350eb65903 "C:\img"
โดยจะ Copy ไฟล์จาก Computer (C:\img) ไปจัดเก็บไว้บน Isolated Storage

หลังจาก Copy ไฟล์เรียบร้อยแล้วสามารถใช้คำสั่ง ISETool.exe dir xd 160bedc0-fd4b-431e-b602-b5350eb65903

เพื่อแสดงรายการไฟล์ที่ถูก Copy ไปไว้บน Isolated Storage
สำหรับบทความนี้เป็นเพียงแค่การทำความเข้าใจเกี่ยวกับ Isolated Storage บน Windows Phone 8 ส่วนการ Copy ไฟล์ การเขียนไฟล์ หรือการ อ่านไฟล์ในรูปแบบต่าง ๆ ทั้ง Text, Image, Media ด้วย Windows Phone 8 สามารถอ่านได้จากส่วนอื่น ๆ ของบทความ
อ่านเพิ่มเติมเกี่ยวกับ Isolated Storage บน Windows Phone 8
.