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]
4 years ago
5

Task 1 – File Input

Computers and Technology
1 answer:
e-lub [12.9K]4 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
A radiologist’s computer monitor has higher resolution than most computer screens. Resolution refers to the:______
netineya [11]

A radiologist’s computer monitor has higher resolution than most computer screens. Resolution refers to the: <u>number of horizontal and vertical pixels on the screen.</u>

<u>Explanation:</u>

The resolution of a screen refers to the size and number of pixels that are displayed on a screen. The more pixels a screen has, the more information is displayed on it without the user having to scroll for it.

More pixels also define and enhance the clarity of the pictures and content displayed on the screen. Pixels combine in different ratios to provide different viewing experiences for users.

6 0
3 years ago
Three reasons why users attach speakers to their computer
Alla [95]
For media sound
For the game's multimedia sound
For essential system sound
5 0
3 years ago
How can you resize the program window?​
Daniel [21]

Answer:

Resize a window by dragging the edges or corner of the window. Hold down Shift while resizing to snap the window to the edges of the screen and other windows. Move or resize a window using only the keyboard. Press Alt + F7 to move a window or Alt + F8 to resize.

4 0
3 years ago
Read 2 more answers
5: what privacy issues have arisen with webcams in mobile devices?
AnnZ [28]

What are the privacy issues that have arisen with webcams and mobile devices? People secretly record and broadcast other people without their permission.

3 0
3 years ago
Write a program to create an interface Shape containing the method declarations of area and perimeter. Then, create a class Rect
irakobra [83]

Answer:

Explanation:

An interface is similar to a class, to create an interface we use interface keyword, in an interface there can be abstract methods and constants only,we can not instantiate an interface.All the variables declared inside an interface are public,static and final  by default.

While using interface child class must use implements keyword

We can define an  interface by using below syntax-

<interface> <interface-name>{

}

For example lets create Shpae interface

interface Shape{

public int area(int length, int width);

public int perimeter(int length, int width);

}

Now lets create Rectangle class-

class Rectangle implements Shape{

public int area(int length, int width){

int area = 0;

area = length * width;

return area;

}

public int perimeter(int length, int width);

int perimeter = 0;

perimeter = 2*(length+width);

return perimeter ;

}

6 0
3 years ago
Other questions:
  • Technlogies are having a negative impact on business true or false
    7·1 answer
  • Deterime the minimum number of multiplication operations needed to compute the following. Show the order of the computations.
    10·1 answer
  • Write a program that produces the following output:
    12·1 answer
  • Which of the following statements is false? Group of answer choices A subclass is often smaller than its superclass. A superclas
    12·1 answer
  • What tab on the ribbon do I go into to create new database objects in Access?
    13·1 answer
  • Which information can you apply to every page of your document with the page layout options?
    9·1 answer
  • The Quick Access tool bar allows you to customize the actions or commands you frequently use.
    13·1 answer
  • Be your self today!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    9·1 answer
  • What are real online jobs any one of any age can get pays weekly by Pay<br> Pal
    8·1 answer
  • _____________ do not contribute to effective group work.
    15·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!