Reputation: 717
I am downloading some .zip files in my UWP app in this way.
var rootFolder = await ApplicationData.Current.LocalFolder.CreateFolderAsync("attachment", CreationCollisionOption.OpenIfExists );
FileInfo fInfo;
this.infoFiles.TryTake(out fInfo);
StorageFile coverpic = await rootFolder.CreateFileAsync(fInfo.FileName, CreationCollisionOption.ReplaceExisting);
try
{
System.Net.Http.HttpClient client = new System.Net.Http.HttpClient();
Uri URI = new Uri(fInfo.Url);
byte[] buffer = await client.GetByteArrayAsync(URI); // Download file
using (Stream stream = await coverpic.OpenStreamForWriteAsync())
stream.Write(buffer, 0, buffer.Length); // Save
StorageFile zipFile = await MyFileHelper.GetFileAsync(rootFolder, fInfo.FileName);
if (fInfo.FileName.ToLower().Contains(".zip"))
{
await UnZipFileAsync(zipFile, rootFolder).ConfigureAwait(false);
if (Instance.DownloadedNotification != null)
{
Instance.DownloadedNotification(fInfo.FileName);
}
if (await rootFolder.TryGetItemAsync("5301.zip") != null)
{
Debug.WriteLine("Soon after Download and Unzip finished 5301.zip exists");
}
else
{
Debug.WriteLine("Soon after Download and Unzip finished 5301.zip doesn't exists");
}
}
else
{
if (Instance.DownloadedNotification != null)
{
Instance.DownloadedNotification(fInfo.FileName);
}
if (await rootFolder.TryGetItemAsync("5301.zip") != null)
{
Debug.WriteLine("Soon after Download and Unzip finished and file name doesn't contain \"zipFile\" 5301.zip exists");
}
else
{
Debug.WriteLine("Soon after Download and Unzip finished and file name doesn't contain \"zipFile\" 5301.zip doesn't exists");
}
}
// return coverpic;
}
catch (Exception e)
{
Debug.WriteLine("Exception Occured--" + e.Message);
}
I am downloading more than 30 files asynchronously. I download 1 file and save it. Then unzip it (actually I am reading the content of the .zip file without unzipping it. Then copy the contained file to the root folder). Once successfully copied I am downloading the 2nd .zip file.
My Problem is while this cycle goes, some already downloaded files are missing from the root folder(.zip file and the unzip file both are missing from the root folder). As an example, let's say 5301.zip file downloaded and unzipped as the first file. If the program is downloading 10th file(5310.zip), this 5301.zip file and the unzipped file both are missing. My files are downloading into
C:\Users\myuser\AppData\Local\Packages\de187d8d-my-app-id-2b3b8a255c7b_tqgs61w0frgtm\LocalState\attachment
Why this happens? Please guide me to resolve this issue. Thank you!
Upvotes: 0
Views: 755
Reputation: 1
if you are using plugin cordova-file-transfer, compiling for windows 22h2, verify if your windows have encrypted drive, this was the problem here, cause the download was make, then dissapear, because of the encryption.
Upvotes: 0