[ C# 10일차 ] 파일 입출력 File.WriteAllText(String, String), File.ReadAllText(String)
왹져박사2023. 1. 13. 01:12
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
namespace Study11
{
class App
{
//생성자
public App()
{
File.WriteAllText("./WriteAllText.txt", "새 파일을 만들고 이 문자열을 파일에 쓴 다음 파일을 닫는다!");
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
namespace Study11
{
class App
{
//생성자
public App()
{
File.WriteAllText("./WriteAllText.txt", "새 파일을 만들고 이 문자열을 파일에 쓴 다음 파일을 닫는다!");
string contents = File.ReadAllText("./WriteAllText.txt");
Console.WriteLine(contents);
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
namespace Study11
{
class App
{
//생성자
public App()
{
File.WriteAllText("./WriteAllText.txt", "새 파일을 만들고 이 문자열을 파일에 쓴 다음 파일을 닫는다!");
string contents = File.ReadAllText("./WriteAllText.txt");
Console.WriteLine(contents);
if (File.Exists("./ReadAllText.txt"))
{
string contents0 = File.ReadAllText("./ReadAllText.txt");
Console.WriteLine(contents0);
}
else
{
Console.WriteLine("파일이 없습니다. ");
}
}
}
}