[英]External Storage for Xamarin on visual studio
我目前正在使用Visual Studio在Xamarin上进行尝试,以尝试构建和创建一个应用程序,该应用程序读取条形码并将从中获取的整数保存在.txt文件中。 我设法使代码都读取并保存了条形码,但是我想知道是否有一种方法可以将其保存在更易于访问的文件中,因为现在将其保存在内部存储中,这是我可以访问的唯一方法通过adb控制台。 我是否可以将整数保存在笔记本电脑上的.txt文件中? 我目前正在实体电话上进行测试,并通过USB电缆将其连接到笔记本电脑。
这是我的代码:
using Android.App;
using Android.Widget;
using Android.OS;
using System;
using Android.Content;
using ZXing.Mobile;
using System.IO;
namespace Scanner
{
[Activity(Label = "Scanner", MainLauncher = true, Icon = "@drawable/icon")]
public class MainActivity : Activity
{
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
// Set our view from the "main" layout resource
SetContentView (Resource.Layout.Main);
Button buttonScan = FindViewById<Button>(Resource.Id.buttonScan);
TextView scanText = FindViewById<TextView>(Resource.Id.scanText);
var documents = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal);
var BarcodesFile = Path.Combine(documents, "Barcodes.txt");
buttonScan.Click += async (sender, e) =>
{
MobileBarcodeScanner.Initialize(Application);
var scanner = new ZXing.Mobile.MobileBarcodeScanner();
var result = await scanner.Scan();
if (result != null)
File.AppendAllText(BarcodesFile, "Scanned Barcode: " + result.Text);
scanText.Text = File.ReadAllText(BarcodesFile);
};
}
}
}
因此,如果api是一个主意。 对于这些要求,我还没有使用过任何api,但是当我想到txt时,我立即想到了pastebin。
https://pastebin.com/api enter code here
这可能对检出有用。 祝好运!;)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.