1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
KonstantinChe [14]
3 years ago
5

Task 1 – File Input

Computers and Technology
1 answer:
e-lub [12.9K]3 years ago
3 0

Answer:

Check the explanation

Explanation:

using System;

using System.IO;

                 

public class Program

{

 

  public static void Main()

  {

      string[] lines;

      Console.WriteLine("enter name of the file");

      String fileName=Console.ReadLine();

     

      Console.WriteLine("enter path of the file");

      String filePath=Console.ReadLine();

     

      using (StreamReader streamReader = File.OpenText(filePath))

      {

          String text = streamReader.ReadToEnd();

          lines = File.ReadAllLines(filePath);

      }

      Console.WriteLine("Enter path of the file to write");

      String outputFilePath = Console.ReadLine();

      bool fileExist = File.Exists(outputFilePath);

      if (fileExist)

      {      

                  overWriteOrChangeFileName(outputFilePath);          

      }

      else

      {

          File.Create(outputFilePath);

          File.WriteAllLines(outputFilePath, lines);

      }

      Console.Write("Input file Path"+filePath);

      Console.Write("output file path"+outputFilePath);

     

      void overWriteOrChangeFileName(String filePathtoCheck){

          Console.WriteLine("File exists. Do you want to overwrite the file or do you want to change the location and file name of the new file.Press Y to overwrite and press C to change the location and filename");

          String userInput=Console.ReadLine();

          if(userInput.Equals("Y")){

File.WriteAllLines(outputFilePath, lines);

          }else{

              Console.WriteLine("enter new path of the file including filename");

              String NewFileName=Console.ReadLine();

              outputFilePath=NewFileName;

              if(File.Exists(outputFilePath)){

                  overWriteOrChangeFileName(outputFilePath);                  

              }

              else

      {

          File.Create(outputFilePath);

          File.WriteAllLines(outputFilePath, lines);

      }

          }

      }

  }

 

}

You might be interested in
If a form-based code is administered, then what does the administration section of the code specifically set forth?
Mamont248 [21]

Answer:

Form-based codes have a description of what uses a building or a place is permitted but focus on the physical character of construction, particularly how they relate to the public realm shared by everybody. More and more people across the country and around our world have seen form-based codes as a more effective and efficient method to accomplish what they want, protect what they care about and escape what they do not want.

Explanation:

In the 1980s a group of architects and designers were trying to construct an alternative to traditional zoning, focusing less on use and more on size, construction speed, the shape of public spaces and the connections between buildings. Throughout this time the Duany Plater-Zyberk & company was planned to create a new community based on traditional neighborhood design concepts, Seaside, Florida, which originally developed an earlier modern type code to direct the development of the new community. The entire municipal code of Seaside was graphically illustrated on one poster as a radical deviation from traditional zoning.

6 0
3 years ago
What does the word tolerance mean in textiles?
Firdavs [7]
It means the willingness to respect or except thecustoms, beliefs, or opinions of others
4 0
3 years ago
What shoul i get, Airpods or a ps4 cooling fan ???
Fynjy0 [20]

Answer:

Airpods, there is ps5 coming out

Explanation:

3 0
2 years ago
Read 2 more answers
Mitchell doesn’t have a checking account, but needs to pay a bill, what can Mitchell pay with?
aleksandr82 [10.1K]
Cash, possibly credit card.
5 0
3 years ago
Read 2 more answers
You can delete any content control by ____ it, and then clicking remove content control on the menu that opens.
Bezzdna [24]
<span>You can delete any content control by Right Clicking it, and then clicking remove content control on the menu that opens.</span>
8 0
3 years ago
Other questions:
  • How to write a self-analysis essay
    5·1 answer
  • 1. A tachometer measures:
    8·1 answer
  • Jim has to send an email to his boss requesting medical leave. in which field will Jim type the purpose of his email?​
    8·2 answers
  • Which of the following statements holds true for the term "html"? It refers to a system that connects end users to the Internet.
    10·2 answers
  • Give a real life of an if statement
    13·1 answer
  • Which attribute defines the file name for the specific image in an image tag??
    13·1 answer
  • Is it true or false and incomplete doing can be saved in Paint​
    15·1 answer
  • Which is the OS that can be obtained for free or at a much lower price than other major operating systems?
    15·2 answers
  • In Tynker, it is not possible to create a/an __________.
    6·2 answers
  • Which of the following shows the correct order of inventions that helped the first computers make calculations?
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!