询问者
\windows 8应用中 文件移动问题

问题
-
文件在移动中出现Value does not fall within the expected range.
以下是代码
string newpath = ApplicationData.Current.LocalFolder.Path + @"\page_" + udid + @".bundle"; StorageFolder storageFolder = await StorageFolder.GetFolderFromPathAsync(ApplicationData.Current.LocalFolder.Path + @"\json_" + udid + @".bundle\"); await sf.MoveAsync(storageFolder, newpath);
全部回复
-
Hi,
await sf.MoveAsync(storageFolder, newpath);这句话中你第二个为什么要传入path的值呢?这个应该是新的文件名才对。有可能是你的文件名不符合规定引起的。
这是MoveAsync的文档:
http://msdn.microsoft.com/en-us/library/windows/apps/br227219.aspx
Aaron
MSDN Community Support | Feedback to us
Develop and promote your apps in Windows Store
Please remember to mark the replies as answers if they help and unmark them if they provide no help. -
Hi,
没有这种API,你需要获取这个文件夹里所有的文件然后一个一个的移动到另一个文件夹中。
Aaron
MSDN Community Support | Feedback to us
Develop and promote your apps in Windows Store
Please remember to mark the replies as answers if they help and unmark them if they provide no help.- 已建议为答案 Jie BaoModerator 2013年4月3日 9:47
-
Hi,
这里有一个WinRT的实现,但是它的效率很慢。而且里面提供了一个使用P/invoke通过Win32API实现移动文件夹,你可以看看:
http://social.msdn.microsoft.com/Forums/en-US/winappswithcsharp/thread/c112b302-03dd-431c-8b90-4adae19ca853
如果你不想使用Win32API的话,而且文件夹也不是很大。可以试试压缩之后,再到目标文件夹解压。
Aaron
MSDN Community Support | Feedback to us
Develop and promote your apps in Windows Store
Please remember to mark the replies as answers if they help and unmark them if they provide no help.