【发布时间】:2014-02-14 09:08:52
【问题描述】:
这是一个用于 android 的 xamarin 应用程序,用于压缩或提取用户在文本框中输入的给定文件。我将示例文件放在 assets 文件夹中。单击按钮时的功能 zip 应该压缩文件在输入文件名并单击按钮时,即使提供了文件所在的路径,它也会引发 filenotfound 异常。
namespace zipfile
{
[Activity (Label = "zipfile", MainLauncher = true)]
public class MainActivity : Activity
{
string t;
protected override void OnCreate (Bundle bundle)
{
base.OnCreate (bundle);
// Set our view from the "main" layout resource
SetContentView (Resource.Layout.Main);
Button button1 = FindViewById<Button> (Resource.Id.button1);
button1.Click += delegate {
EditText text = FindViewById<EditText>
(Resource.Id.editText2);
if (null == text)
return;
t="\\zip\\zipfile\\Assets\\"+ text.Text;
//Toast.MakeText(this,"file
zipped",ToastLength.Long).Show();
ZipOutputStream.Zip(t, t, 128);
};
Button button2 = FindViewById<Button> (Resource.Id.button2);
button2.Click += delegate {
//Toast.MakeText(this,"file
unzipped",ToastLength.Long).Show();
ZipInputStream.UnZip (t, t, 128);
};
}
}
}
我是 Xamarin 的新手,请建议我处理此异常的方法。
【问题讨论】: