C# visual studio上Xamarin的外部存储

C# visual studio上Xamarin的外部存储,c#,android,visual-studio,xamarin,C#,Android,Visual Studio,Xamarin,我目前正在使用Visual Studio开发Xamarin,尝试构建并创建一个应用程序,该应用程序可以读取条形码,并将从条形码中获取的整数保存在一个.txt文件中。我已经设法使代码读取条形码并保存,但是我想知道是否有一种方法可以将其保存在一个更容易访问的文件中,因为现在它保存在内部存储器中,我唯一可以访问它的方法是通过adb控制台。 有没有办法将整数保存在笔记本电脑的.txt文件中?我目前正在我的物理手机上测试它,它通过USB电缆连接到我的笔记本电脑 这是我的密码: using Android.

我目前正在使用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);
            };
        }

    }
}
使用Android.App;
使用Android.Widget;
使用Android.OS;
使用制度;
使用Android.Content;
使用ZXing.Mobile;
使用System.IO;
名称空间扫描程序
{
[活动(Label=“Scanner”,MainLauncher=true,Icon=“@drawable/Icon”)]
公共课活动:活动
{
创建时受保护的覆盖无效(捆绑包)
{
base.OnCreate(bundle);
//从“主”布局资源设置视图
SetContentView(Resource.Layout.Main);
Button buttonScan=FindViewById(Resource.Id.buttonScan);
TextView scanText=FindViewById(Resource.Id.scanText);
var documents=System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal);
var BarcodesFile=Path.Combine(文档,“Barcodes.txt”);
按钮扫描。单击+=异步(发送方,e)=>
{
MobileBarcodeScanner.Initialize(应用程序);
var scanner=new ZXing.Mobile.MobileBarcodeScanner();
var result=wait scanner.Scan();
如果(结果!=null)
文件.AppendAllText(条形码文件,“扫描条形码:”+结果.Text);
scanText.Text=文件.ReadAllText(条形码文件);
};
}
}
}

如果api是一个想法。我还没有为这些需求使用任何api,但当我想到txt时,我立即想到了pastebin

在此处输入代码


这可能有助于退房。祝你好运

是否可以使用外部数据库或internet上的文件?有一些api的网站,你可以写在一个txt文件,可以实际工作。我不知道这些存在,但我现在就去看看。谢谢:)虽然我认为pastebin是个好主意,但我想我更愿意将它保存在桌面上的一个文件中。但我会试试的。也许可以找一个像谷歌驱动的api,一个驱动。然后你可以将你的电脑与其中一个驱动器同步?但是我无法从笔记本电脑访问手机中的内部文件吗?你必须在你的电脑上托管一项服务,而不是?或者尝试用蓝牙发送。我只想使用谷歌驱动api,因为它更容易创建并为您进行同步。