Hello, It seems that for some reason the file is not being 'registered' as an actual asset file, even if being bundled with the apk.
To do so, click on the file on the solution explorer, and then change "Build action" to "AndroidAsset" in the properties window. Carlos. 2011/5/24 david.chhang <[email protected]> > Hi, > > I just want to access to a .txt file in the assets folder. this is my code > : > > protected override void OnCreate (Bundle bundle) > { > base.OnCreate (bundle); > > var tv = new TextView(this); > string s = ""; > > try{ > Stream input = Assets.Open("test.txt"); > StreamReader st = new StreamReader(input); > > string ligne = st.ReadLine(); > > while (ligne != null) > { > s +=ligne+"\n"; > ligne = st.ReadLine(); > } > > st.Close(); > } > catch(Exception e){ > s += "Message d'erreur :\n"+e.Message; > } > > tv.Text = "TEXTE : "+s; > > SetContentView(tv); > } > > And when I test my application, it displays "Exception of type > 'Java.IO.FileNotfoundException' was thrown. So, they don't find my file > whereas I put the "test.txt" in the Assets folder. Why ? > > -- > View this message in context: > http://mono-for-android.1047100.n5.nabble.com/Problem-to-access-assets-files-tp4422037p4422037.html > Sent from the Mono for Android mailing list archive at Nabble.com. > _______________________________________________ > Monodroid mailing list > [email protected] > > UNSUBSCRIBE INFORMATION: > http://lists.ximian.com/mailman/listinfo/monodroid >
_______________________________________________ Monodroid mailing list [email protected] UNSUBSCRIBE INFORMATION: http://lists.ximian.com/mailman/listinfo/monodroid
