簡體   English   中英

Xamarin在Visual Studio上的外部存儲

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM