私はWindows 10、Visual Studio 2015、およびXamarinを実行しています。私はXamarin(地面レベルを設定する)にはむしろ新しいです。私は最近、私が最近更新した後に問題を抱えています。私のアプリケーションはアップデート前に動作していました。私のすべてのファイルは読み取り専用で、更新前に問題はありませんでした。それに加えて、私はプロジェクトを再構築しました。私はプロジェクトのための「クリーンで再構築」しています。私は私が持っている複数のアプリケーションでそれを試して、他のアプリケーションはこの問題がありません。問題以下のエラーが発生しています。パスへのアクセスが拒否されました(Xamarin/Android)
06-26 13:51:55.108 I/MonoDroid(6985): UNHANDLED EXCEPTION:
06-26 13:51:55.142 I/MonoDroid(6985): System.UnauthorizedAccessException: Access to the path "/storage/emulated/0/defaultDirectory/users.ini" is denied.
06-26 13:51:55.142 I/MonoDroid(6985): at System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, System.Int32 bufferSize, System.Boolean anonymous, System.IO.FileOptions options) [0x001f1] in <3fd174ff54b146228c505f23cf75ce71>:0
06-26 13:51:55.142 I/MonoDroid(6985): at System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, System.Int32 bufferSize, System.IO.FileOptions options, System.String msgPath, System.Boolean bFromProxy, System.Boolean useLongPath, System.Boolean checkHost) [0x00000] in <3fd174ff54b146228c505f23cf75ce71>:0
06-26 13:51:55.142 I/MonoDroid(6985): at (wrapper remoting-invoke-with-check) System.IO.FileStream:.ctor (string,System.IO.FileMode,System.IO.FileAccess,System.IO.FileShare,int,System.IO.FileOptions,string,bool,bool,bool)
06-26 13:51:55.142 I/MonoDroid(6985): at System.IO.StreamReader..ctor (System.String path, System.Text.Encoding encoding, System.Boolean detectEncodingFromByteOrderMarks, System.Int32 bufferSize, System.Boolean checkHost) [0x00067] in <3fd174ff54b146228c505f23cf75ce71>:0
06-26 13:51:55.142 I/MonoDroid(6985): at System.IO.StreamReader..ctor (System.String path, System.Text.Encoding encoding, System.Boolean detectEncodingFromByteOrderMarks, System.Int32 bufferSize) [0x00000] in <3fd174ff54b146228c505f23cf75ce71>:0
06-26 13:51:55.142 I/MonoDroid(6985): at System.IO.StreamReader..ctor (System.String path, System.Boolean detectEncodingFromByteOrderMarks) [0x0000d] in <3fd174ff54b146228c505f23cf75ce71>:0
06-26 13:51:55.142 I/MonoDroid(6985): at System.IO.StreamReader..ctor (System.String path) [0x00000] in <3fd174ff54b146228c505f23cf75ce71>:0
06-26 13:51:55.142 I/MonoDroid(6985): at (wrapper remoting-invoke-with-check) System.IO.StreamReader:.ctor (string)
06-26 13:51:55.142 I/MonoDroid(6985): at System.IO.File.OpenText (System.String path) [0x00000] in <3fd174ff54b146228c505f23cf75ce71>:0
06-26 13:51:55.142 I/MonoDroid(6985): at QykAndroidApp.AdminLoginActivity.decryptUsers() [0x00033] in <65a7af1659a443738d96e6c2b7534ab2>:0
06-26 13:51:55.142 I/MonoDroid(6985): at QykAndroidApp.AdminLoginActivity.OnCreate (Android.OS.Bundle savedInstanceState) [0x0008a] in <65a7af1659a443738d96e6c2b7534ab2>:0
06-26 13:51:55.142 I/MonoDroid(6985): at Android.App.Activity.n_OnCreate_Landroid_os_Bundle_ (System.IntPtr jnienv, System.IntPtr native__this, System.IntPtr native_savedInstanceState) [0x0000f] in <d855bac285f44dda8a0d8510b679b1e2>:0
06-26 13:51:55.142 I/MonoDroid(6985): at (wrapper dynamic-method) System.Object:28564880-3429-412d-9c61-4f5bb9fc103e (intptr,intptr,intptr)
06-26 13:51:55.153 W/art (6985): JNI RegisterNativeMethods: attempt to register 0 native methods for android.runtime.JavaProxyThrowable
An unhandled exception occured.
私は、(私が上位の結果のほとんどすべてを読んだので、3番目の項目のGoogle検索を投稿しました)などの記事はほとんど読んでいません。私は管理者としてプログラムを実行しようとしましたが、ディレクトリは誰にでもアクセスできます。私は私のファイルにアクセスしていますがどのようにコードの好奇心誰のため
- Why is access to the path denied?
- System.UnauthorizedAccessException: Access to the path "..." is denied
- https://www.google.com/search?q=RegisterNativeMethods%3A+attempt+to+register+0+native+methods+for+android.runtime.JavaProxyThrowable&oq=RegisterNativeMethods%3A+attempt+to+register+0+native+methods+for+android.runtime.JavaProxyThrowable&aqs=chrome..69i57j69i58.572j0j7&sourceid=chrome&ie=UTF-8
、それは以下の通りです。
private List<string> readUsers()
{
adminUsers = new List<string>();
try
{
StreamReader readerForFile;
//create checks for making sure the card is mounted, the directory is found, and the file is found.
var filePath = Path.Combine(Android.OS.Environment.ExternalStorageDirectory.Path, "defaultDirectory/users.ini");
File.SetAttributes(filePath, FileAttributes.Normal);
if (File.Exists(filePath))
{
//Reads enttire document
//var fillContent = File.ReadAllText(filePath);
readerForFile = File.OpenText(filePath);
if (readerForFile == null) { return null; }
else
{
string line = "";
int counter = 0;
while ((line = readerForFile.ReadLine()) != null)
{
adminUsers.Add(line);
counter++;
}
}
}
}
catch (IOException e)
{
//You'll need to add proper error handling here
alert.SetMessage("File was not found. " + e).SetNeutralButton("Okay", delegate { QuestionActivity.exit(); }).Create().Show();
}
return adminUsers;
}
"私のアプリケーションはアップデート前に動作していました。デバイスからアプリをアンインストールして、もう一度デプロイしてみてください。 –