-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOOP_2020 Q4-b.cs
More file actions
34 lines (34 loc) · 894 Bytes
/
Copy pathOOP_2020 Q4-b.cs
File metadata and controls
34 lines (34 loc) · 894 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
using System;
using System.Collections.Generic;
using System.Text;
namespace program
{
public class Program
{
static void read(string path)//2 read all lines and store it in string array
{
string[] lines;
lines = File.ReadAllLines(path);
for(int i = 0; i < lines.Length; i++)
{
Console.WriteLine(lines[i]);
}
}
static void Main(string[] Args)
{
string path = @"d:\test.txt";
bool exist = false;
if(File.Exists(path))//1 exists?
{
exist = true;
}
if (exist)
{
read(path);//2
File.Copy(path, @"G:\test.txt");//3 copy to another txt file
}
else
Console.WriteLine("File Not Found!");
}
}
}