수동
를 사용하여 기존의 윈도우 폰 격리 된 저장소 탐색기 도구
프로그래밍
파일 사본을 작성해야합니다. ... 파일
StreamResourceInfo streamInfo = Application.GetResourceStream(new Uri("CordovaSourceDictionary.xml", UriKind.Relative));
if (streamInfo != null)
{
StreamReader sr = new StreamReader(streamInfo.Stream);
//This will Read Keys Collection for the xml file
XDocument document = XDocument.Parse(sr.ReadToEnd());
var files = from results in document.Descendants("FilePath")
select new
{
path = (string)results.Attribute("Value")
};
StreamResourceInfo fileResourceStreamInfo;
using (IsolatedStorageFile appStorage = IsolatedStorageFile.GetUserStoreForApplication())
{
foreach (var file in files)
{
fileResourceStreamInfo = Application.GetResourceStream(new Uri(file.path, UriKind.Relative));
if (fileResourceStreamInfo != null)
{
using (BinaryReader br = new BinaryReader(fileResourceStreamInfo.Stream))
{
byte[] data = br.ReadBytes((int)fileResourceStreamInfo.Stream.Length);
string strBaseDir = AppRoot + file.path.Substring(0, file.path.LastIndexOf(System.IO.Path.DirectorySeparatorChar));
if (!appStorage.DirectoryExists(strBaseDir))
{
Debug.WriteLine("INFO: Creating Directory :: " + strBaseDir);
appStorage.CreateDirectory(strBaseDir);
}
// This will truncate/overwrite an existing file, or
using (IsolatedStorageFileStream outFile = appStorage.OpenFile(AppRoot + file.path, FileMode.Create))
{
Debug.WriteLine("INFO: Writing data for " + AppRoot + file.path + " and length = " + data.Length);
using (var writer = new BinaryWriter(outFile))
{
writer.Write(data);
}
}
}
}
else
{
Debug.WriteLine("ERROR: Failed to write file :: " + file.path + " did you forget to add it to the project?");
}
}
}
}
그것이 작동하지 아래 IsolatedStorage에 코드를 사용하여
그런 다음 복사 할 파일을 이동해야합니다 지정합니다 프로젝트의 일환으로 CordovaSourceDictionary.xml가 가정 : ( – user1273180
사전 파일 이름을 SourceDictionary.xml로 지정했지만 CordovaSourceDictionary.xml이어야합니다. https://github.com/apache/incubator-cordova-wp7/tree/master/example에서 전체 예제를 찾을 수 있습니다. –