转换的Android code到MonoAndroid code [英] Convert Android Code to MonoAndroid Code
本文介绍了转换的Android code到MonoAndroid code的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何转换以下的Android code到MonoAndroid code?
How do I convert the following Android code to MonoAndroid code?
//Open your local db as the input stream
InputStream myInput = myContext.getAssets().open(DB_NAME);
// Path to the just created empty db
String outFileName = DB_PATH + DB_NAME;
//Open the empty db as the output stream
OutputStream myOutput = new FileOutputStream(outFileName);
//transfer bytes from the inputfile to the outputfile
byte[] buffer = new byte[1024];
int length;
while ((length = myInput.read(buffer))>0){
myOutput.write(buffer, 0, length);
}
//Close the streams
myOutput.flush();
myOutput.close();
myInput.close();
和是否有使用说明任何特殊的dll引用或?
And are there any special dll references or using statements?
感谢
推荐答案
在摆弄周围的天徒劳的google搜索,Assets.Open(@test.db的)'是关键:
After days of fiddling around and futile googling, 'Assets.Open(@"test.db")' was the key:
//Open your local db as the input stream
Stream myInput = Assets.Open(@"test.db");
string outFileName = Path.Combine(System.Environment.GetFolderPath (System.Environment.SpecialFolder.Personal), "test.db");
//Open the empty db as the output stream
Stream myOutput = new FileStream(outFileName,FileMode.OpenOrCreate);
byte[] buffer = new byte[1024];
int b = buffer.Length;
int length;
while ((length = myInput.Read(buffer,0,b))>0){
myOutput.Write(buffer, 0, length);
}
//Close the streams
myOutput.Flush();
myOutput.Close();
myInput.Close();
}
这篇关于转换的Android code到MonoAndroid code的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文