On Mar 27, 2012, at 6:21 PM, Paul Johnson wrote:
> I'm trying to write to the SDCard with the following code (which was
> suggested on here), but I'm getting a null reference error on the
> Path.Combine line - I've no idea why either!
>
> var external = GetExternalFilesDir(null);
> var dir = Path.Combine(external.AbsolutePath, "OQHRA");
> if (!File.Exists(dir))
> {
> System.IO.Directory.CreateDirectory(dir);
> }
As Miha suggested, `external` is probably null. Context.GetExternalFilesDir()
will return null when external storage is mounted by a host computer:
http://androidapi.xamarin.com/?link=M:Android.Content.Context.GetExternalFilesDir
http://developer.android.com/reference/android/content/Context.html#getExternalFilesDir(java.lang.String)
"Returns null if external storage is not currently mounted so it could
not ensure the path exists; you will need to call this method again when it is
available."
- Jon
_______________________________________________
Monodroid mailing list
[email protected]
UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid