Skip to main content
Question

File download stops after downloading first 4-8 files

  • May 22, 2025
  • 2 replies
  • 53 views

Forum|alt.badge.img

Hello, We are running into strange issue when downloading files using Box.V2 .NET APIs. We wrote console application to make connection, download all files in the folder. Code works fine until it has downloaded first 4-6 files and then it will get stuck there. Line in RED what is causing the problem. I created ticket for Box team and they mentioned there is no such limitation imposed by them. We are also having a paid account of Box (Business plus)

 

private async Task Run()

{

            BoxClient userClient=await InitializeConnection();

            BoxFolder root = await userClient.FoldersManager.GetInformationAsync("0");

            List allFiles=await ListFolder(root, userClient,null);

 

                foreach (string file in allFiles)

              {

                    try

                    {

                 

                                               Download(file, true, userClient);

                       

                       }

                              catch (Exception ex)

                              {

 

                                             if (ex.Message.ToLower().Contains("canceled"))

                                             throw ex;

                             }

                       }

   }

 

 

    private async Task Download(string fileId,  bool isFile,BoxClient client)

        {

            BoxFile fileInfo=null;

            try

            {

                fileInfo = await client.FilesManager.GetInformationAsync(fileId);

                ExternalDocumentEntity eDoc = new ExternalDocumentEntity();

                eDoc.Path = folder;

                eDoc.Id = fileInfo.Id;

           

                eDoc.Description = fileInfo.Description;

                if (fileInfo.VersionNumber != null)

                {

                    eDoc.ChangeInformation = fileInfo.VersionNumber.ToString();

                 

                }

                eDoc.ContentHash = fileInfo.FileVersion.Sha1;

                eDoc.CreatedBy = fileInfo.CreatedBy.Login;

                eDoc.CreatedDate = fileInfo.CreatedAt.Value;

                eDoc.ModifiedBy = fileInfo.ModifiedBy.Login;

                eDoc.ModifiedDate = fileInfo.ModifiedAt.Value;

                //If file is locked by the user on Box

                if (fileInfo.Lock != null)

                {

                    eDoc.LockedBy = fileInfo.Lock.CreatedBy.Login;

                    eDoc.LockedDate = fileInfo.Lock.CreatedAt.Value;

                }

 

                //Do not read the content if checksum value is same. If the file doesnt exist it will return 0

                if (!ExternalData.GetInstance(clientName).IsFileChanged(fileInfo.Id, eDoc.ContentHash, clientName))

                {

                    Extensions.ReadAllBytes(await client.FilesManager.DownloadStreamAsync(fileId));

                }

               

                eDoc.FileSize = (ulong)fileInfo.Size.Value;

              

                

                //eDoc.IsDeleted = fileInfo.Type.

                if (isFile)

                    eDoc.IsFile = isFile;

                else

                    eDoc.IsFolder = isFile;

                eDoc.SharedFolderId = fileInfo.Parent.Id;

}

2 replies

Forum|alt.badge.img

 Does the SDK return an error? Or is the connection just timing out? 


Forum|alt.badge.img

There is no error code from Box, it's just timing out. I have attached a screenshot for the exception as well. It shows inner exception is null.