C#/수업 내용

[C#] 파일 시스템 text, json

JSH1 2021. 9. 8. 14:50
            using System.IO; // using 지시문으로 네임스페이스 추가

            // ./ :현재 디렉토리 위치
            string path = "./helloworld.txt";
            string txt = File.ReadAllText(path);
            Console.WriteLine(txt);


            using System.IO; // using 지시문으로 네임스페이스 추가

            // ./ :현재 디렉토리 위치
            string path = "./Datas/helloworld.txt";
            string txt = File.ReadAllText(path);
            Console.WriteLine(txt);

            string contents = "hello";
            File.WriteAllText(path, contents);

            txt = File.ReadAllText(path);
            Console.WriteLine(txt);


            using System.IO; // using 지시문으로 네임스페이스 추가

            string path = "./item_data.json";
            string json = File.ReadAllText(path);
            Console.WriteLine(json);


 

'C# > 수업 내용' 카테고리의 다른 글

[C#] Newtonsoft.Json 파일 읽기, 역직렬화  (0) 2021.09.08
[C#] Newtonsoft.Json 설치  (0) 2021.09.08
[C#] LINQ  (0) 2021.09.08
[C#] Func 복습  (0) 2021.09.08
[C#] Action 복습  (0) 2021.09.08