Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7590665
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T20:27:41+00:00 2026-05-30T20:27:41+00:00

im writing a file transfer application to send and receive a large data like

  • 0

im writing a file transfer application to send and receive a large data like 1 GB.. but i think when i read the data from the file and fill it into a byte array it stored on RAM and that would effect on the computer speed .. should i do like :

(loop till end of the file)
{
   read 128 MB from the file into byte array
   (loop till end of 128)
   {
       send 1 kb to server
   }
   byte array = null
}

if that is right ..
which is better to do !! beginSend and beginReceive to send the large file or just loop to send the file

i would be glad if you teach me with some code
thanks in advance 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T20:27:42+00:00Added an answer on May 30, 2026 at 8:27 pm

    even 128mb is not a good way .. its better to read a small buffer .. then send it straight to the other side

    check it out.

    after you send the fileName and the fileSize to other side

    this should be common in (server/client)

    FileStream fs;
    NetworkStream network;
    int packetSize = 1024*8;
    

    Send method

    public void Send(string srcPath, string destPath)
        {
            byte data;
            string dest = Path.Combine(destPath, Path.GetFileName(srcPath));
            using (fs = new FileStream(srcPath, FileMode.Open, FileAccess.Read))
            {
                try
                {
                    long fileSize = fs.Length;
                    long sum = 0;
                    int count = 0;
                    data = new byte[packetSize];
                    while (sum < fileSize)
                    {
                        count = fs.Read(data, 0, packetSize);
                        network.Write(data, 0, count);
                        sum += count;
                    }
                    network.Flush();
                }
                finally
                {
                    fs.Dispose();
                    data = null;
                }
            }
        }
    

    Receive method:

        public void Receive(string destPath, long fileSize)
        {
            byte data;
            using (fs = new FileStream(destPath, FileMode.Create, FileAccess.Write))
            {
                try
                {
                    int count = 0;
                    long sum = 0;
                    data = new byte[packetSize];
                    while (sum < fileSize)
                    {
                        count = network.Read(data, 0, packetSize);
                        fs.Write(data, 0, count);
                        sum += count;
                    }
                }
                finally
                {
                    fs.Dispose();
                    data = null;
                }
            }
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am writing a data transfer application using a servlet and would like to
I'm writing a file transfer application in VC++(Server) using UDP. I came to know
I need to transfer all data from a OLEDB source to XML file and
I'm writing a Cocoa app that will need access to multiple file transfer protocols,
I would like to store some Application-Related Metadata for Files, and NTFS Alternate Data
I have a simple file transfer socket program where one socket sends file data
I'm trying to save a file (pdf or image) uploaded from a form into
I have implemented a read/write stream to read a buffer, manipulate the data(like adding
I am writing code for uploading a file from a client to my server
I'm writing a mule application that implements some web services using Jersey. I'd like

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.