我收到错误:
Access to the path '/storage/emulated/0/MobileSell/backup/fromserver' is denied
当我试图在fromserver
文件夹中保存zip文件时:
System.IO.File.WriteAllBytes(GlobalVariables.fromserverFolderPath, basedataZipFile);
我传递给WriteAllBytes方法的变量值是:
GlobalVariables.fromserverFolderPath = Android.OS.Environment.ExternalStorageDirectory.ToString() + "/MobileSell/backup/fromserver";
byte[] basedataZipFile = resultFromService[0];
我在AndroidManifest.xml中设置了权限
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
这一直有效,但它在30分钟前开始出错。你知道原因可能是什么吗?以下是屏幕上fromserver
文件夹的截图:
我找到了解决方案。在方法中:
System.IO.File.WriteAllBytes(GlobalVariables.fromserverFolderPath, basedataZipFile);
指定我要保存zip
的路径的一部分我还必须指定zip
文件名。所以看起来像这样:
System.IO.File.WriteAllBytes(GlobalVariables.fromserverFolderPath + "/" + basedataZipName, basedataZipFile);
它有效。奇怪的是,我之前没有必要指定zip文件的名称并且它有效。无论如何...