我正在一个名为“webapplication”的文件夹中创建一个带有静态html文件的windows phone项目。我想将“webapplication”文件夹的所有内容存储在独立存储中。有人可以帮助解决这个问题吗?在独立存储中存储项目文件夹
0
A
回答
0
查看windows phone geek http://windowsphonegeek.com/tips/all-about-wp7-isolated-storage-files-and-folders了解隔离存储的信息。
要创建一个文件夹,请执行以下操作:
IsolatedStorageFile myIsolatedStorage = IsolatedStorageFile.GetUserStoreForApplication();
myIsolatedStorage.CreateDirectory("NewFolder");
如果你想创建该文件夹中的文件,然后:
IsolatedStorageFile myIsolatedStorage = IsolatedStorageFile.GetUserStoreForApplication();
StreamWriter writeFile = new StreamWriter(new IsolatedStorageFileStream("NewFolder\\SomeFile.txt", FileMode.CreateNew, myIsolatedStorage));
如果您正在寻找将文件复制到IsolatedStorage,然后您需要在第一次执行应用程序时运行以下代码:
using (IsolatedStorageFile storage = IsolatedStorageFile.GetUserStoreForApplication())
{
string[] files = System.IO.Directory.GetFiles(folderPath);
foreach (var _fileName in files)
{
if (!storage.FileExists(_fileName))
{
string _filePath = _fileName;
StreamResourceInfo resource = Application.GetResourceStream(new Uri(_filePath, UriKind.Relative));
using (IsolatedStorageFileStream file = storage.CreateFile("NewFolder\\SomeFile.txt", FileMode.CreateNew, Storage))
{
int chunkSize = 102400;
byte[] bytes = new byte[chunkSize];
int byteCount;
while ((byteCount = resource.Stream.Read(bytes, 0, chunkSize)) > 0)
{
file.Write(bytes, 0, byteCount);
}
}
}
}
}
相关问题
- 1. 在独立存储中存储IList
- 2. EGit在存储库中创建单独的项目文件夹
- 3. 将文件存储在独立存储器中
- 4. .NET“独立存储”存储在哪里?
- 5. Silverlight独立存储
- 6. 将数据存储到存储器中的独立存储器
- 7. 将在线XML文件中的条目写入独立存储
- 8. 写入文件(?独立存储wp7)
- 9. 如何显示存储在独立存储中的文本文件?
- 10. 将轴心项目作为独立存储中的目录
- 11. 独立存储vs应用程序数据文件夹
- 12. 是否可以通过URI引用存储在独立存储中的文件?
- 13. 播放存储在独立存储器中的大型录制音频文件
- 14. 如何修改存储在独立存储器内的xml文件中的值?
- 15. 保存WP7中Microsoft Office中的独立存储文件
- 16. 在eclipse项目文件夹中的文件存储在外部存储中的文件?
- 17. 将数组转换为文本文件并存储到独立存储中
- 18. 启动存储在独立存储中的EXE
- 19. 在独立存储中存储字符串数组?
- 20. 如何从独立存储
- 21. WP 7的独立存储
- 22. 备份独立存储
- 23. Windows phone的独立存储
- 24. 下载文件并将其保存在独立存储
- 25. 保存并读取独立存储中的文件
- 26. 将图像存储到windows phone 7中的独立存储中
- 27. 在windows phone中播放独立存储中的媒体文件?
- 28. 我无法保存到独立存储?
- 29. Silverlight独立存储被视为永久存储或缓存吗?
- 30. Laravel 5.1 - 显示存储在存储文件夹中的图像
本网站基于mu实际的尊重和反馈!我看到你是一个新用户,但如果解决方案有帮助,你应该回应并感谢那些懒得花时间回答问题的人。 – Saurabh 2013-02-13 13:35:47