小编Ang*_*Dev的帖子

追加到 .NET Core 3.1 中 Azure blob 文件的末尾,而不下载整个文件

我需要附加到 Azure blob 文件的末尾,我想知道是否有一种方法可以做到这一点,而无需下载整个 blob 文件。我已经四处搜索,但似乎大多数答案都使用现已弃用的程序集。我弄清楚如何在 .NET Core 3.1 中执行此操作的唯一方法是使用下面的代码。有没有更有效的方法来做到这一点?我知道,根据我的要求,这个文件最终会变得非常大,并且下载整个文件只是为了在其末尾添加一个快速行可能会变得效率低下。

我正在使用程序集 Azure.Storage.Blobs

public static void BlobAppender()
    {
        BlobClient bc = new BlobClient("my azure connection string", "mycontainer", "myblobfile");

        var testStream = bc.OpenRead();
        StringBuilder SB = new StringBuilder();

        using (StreamReader sm = new StreamReader(testStream))
        {
            string temp;
            while ((temp = sm.ReadLine()) != null)
            {
                SB.AppendLine(temp);
            }
        }

        //I append the line here, then reupload.
        SB.AppendLine("My new line");

        byte[] byteArray = Encoding.UTF8.GetBytes(SB.ToString());
        MemoryStream stream = new MemoryStream(byteArray);

        bc.Upload(stream, overwrite: true);

    }
Run Code Online (Sandbox Code Playgroud)

c# azure azure-blob-storage asp.net-core-3.1

2
推荐指数
1
解决办法
1376
查看次数

MAUI 在查看模型列表中未找到属性

我有一个简单的视图模型,其中一个属性包含模型,另一个属性包含模型列表。

我可以毫无问题地绑定“Test”模型的属性,但无法让 XAML 识别“ListModel”包含具有其自己的属性的列表。我已经查看了几个示例,了解如何设置视图模型并在将列表绑定到视图之前正确初始化列表,虽然 XAML 理解“ListModel”是一个属性,但我无法让它识别出它是一个属性。列表,因此它不会编译,这样我至少可以看看它是否不是智能感知可能因某种原因而失败。

这是有问题的视图模型,其列表名为“ListModel”

public class TestViewModel
{        
    public TestModel Test { get; } = new TestModel();
    public List<TestListModel> ListModel { get; set; }


    public TestViewModel()
    {
        Initialize();
    }

    public void Initialize()
    {
        ListModel = new List<TestListModel>();
        ListModel.Add(new TestListModel
        {
            ListProp1 = "First",
            ListProp2 = "Second",
            ListProp3 = "Third"
        });
    }     
}
Run Code Online (Sandbox Code Playgroud)

这是正在放入列表中的模型。视图似乎没有看到这些属性。

public class TestListModel
    {        
        public string ListProp1 { get; set; }
        public string ListProp2 { get; set; }
        public string ListProp3 { get; set; …
Run Code Online (Sandbox Code Playgroud)

c# xaml maui

2
推荐指数
1
解决办法
3475
查看次数

标签 统计

c# ×2

asp.net-core-3.1 ×1

azure ×1

azure-blob-storage ×1

maui ×1

xaml ×1