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 8167947
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T20:21:56+00:00 2026-06-06T20:21:56+00:00

I m developing an application that reads files from a remote server and copies

  • 0

I m developing an application that reads files from a remote server and copies it onto the local drive.

The code I m using to read and write the file is –

string saveTo1 = savePath + @"\" + filename[i];
                byte[] buffer = new byte[32768];
                using (Stream input = getResponse.GetResponseStream())
                {
                    using (FileStream output = new FileStream(saveTo1, FileMode.OpenOrCreate))
                    {
                        int bytesRead;

                        while ((bytesRead = input.Read(buffer, 0, buffer.Length)) > 0)
                        {
                            output.Write(buffer, 0, bytesRead);
                        }
                        output.Close();
                    }
                }

How can I create a log file that keeps track of the details of file copy and also records if there is any error while copying the files?

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-06-06T20:21:59+00:00Added an answer on June 6, 2026 at 8:21 pm

    You can log in different ways.

    • EventLogger (as already suggested)
    • Custom file log (as already
      answered)
    • Log Engine: I suggest you
      log4net. It’s very powerfull
      and highly customizable.

    Any way, I would shape the code in this way, where MyLogManager implement one of the previous solutions:

    string saveTo1 = savePath + @"\" + filename[i];
    byte[] buffer = new byte[32768];
    try
    {
                using (Stream input = getResponse.GetResponseStream())
                {
                    using (FileStream output = new FileStream(saveTo1, FileMode.OpenOrCreate))
                    {
                        int bytesRead;
    
                        while ((bytesRead = input.Read(buffer, 0, buffer.Length)) > 0)
                        {
                            output.Write(buffer, 0, bytesRead);
                        }
                        output.Close();
                    }
                }
        //logging good news and info
        MyLogManager("Good news", FileDetails);
    }
    catch(Exception ex)
    {
        //logging bad news and exceptions info
        MyLogManager("Bad news", ExceptionDetails);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am developing, in VB.Net, an application that reads from text files using a
I am developing an application that needs to read back the whole frame from
I'm developing an application that reads data from a serial port and sends it
I'm developing a Cocoa/Objective C application that reads the active document from any application
I am developing a program that need read/write some files from sdcard or internal
I'm currently developing an application that will be run on local network in B2B
I'm developing an application that uses webservices in python, both sides (server and client)
I am developing an application that is required to retreive information from an XML
Background: I'm developing a WinForms application using C# with an OpenFileDialog and FileBrowserDialog that
i am developing an application that gathers a list with all the files of

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.