Closed msh2050 closed 10 months ago
I've just fixed the Web demo so it at least runs... it's going to require a little bit of work
Browser app really isn't behaving well.
Posted some issues there https://github.com/AvaloniaUI/Avalonia/issues/14065
I managed to make it work with the browser and I added the upload status this is my code `maybe you need to remove some extra code that I add for my specific needs'
var ms = new MemoryStream();
var settings = GetSettings();
var result = await _dialogService.ShowOpenFileDialogAsync(this, settings);
IProgress<long> progress = new SynchronousProgress<long>(value =>
{
ProgressBarCurrentValue = value;
StatusText = value.ToString();
});
if (result?.Path != null)
{
StatusText = result.Name;
using var stream = result.OpenReadAsync();
StatusText += " Open Read Done";
//await stream.Result.CopyToAsync(ms);
await stream.ContinueWith(async t =>
{
StatusText += " getting the result";
var streamResult = t.Result;
StatusText += " Result size: " + streamResult.Length + " starting copy to memory";
await streamResult.CopyToAsync(ms, progress, source.Token, 1024);
StatusText += "Done";
ms.Position = 0;
StatusText += " size:" + ms.Length;
await ReadExcel(ms).ConfigureAwait(false);
});
}
Oh perfect!
I'll add this to the samples.
btw where do you get your source.Token
?
btw where do you get your
source.Token
?
static readonly CancellationTokenSource source = new ();
you just created your own to have a cancel button?
You just created your own to have a cancel button?
yes, but I have not implemented it yet. I just want to test this but I may not need it since I have no large files to upload
I'm using Avalonia 11.05 with .net7 the
result.OpenReadAsync()
is working with desktop and Android but not with the Web platform. how can I check if the file is loaded successfully? And in the case of larga file, how I can read the file uploading status.