본문 바로가기
C#/수업내용

[ C# 10일차 ] File.Exists(String)

by 왹져박사 2023. 1. 13.
728x90

오류! 아무 생각 없이 프로젝트 이름을 File로 지정했는데, File.Exists가 자꾸 오류가 나 봤더니 키워드가 아닌 네임스페이스로 계속 접근하고있었다.. :) 이를 잊고 집에 와서 복습하며 같은 실수를 하여 기록을 남긴다!


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()
        {
            Console.WriteLine("App");

            //절대경로
            //C:\Users\s2nhl\OneDrive\Documents\csh\File\File\bin\Debug

            //상대경로
            //./내 위치

            bool exists = File.Exists("./memo.txt");
            Console.WriteLine(exists);

            exists = Directory.Exists("./data");
            Console.WriteLine(exists);
        }
    }
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Study11
{
    class Program
    {
        static void Main(string[] args)
        {
            App app = new App();
        }
    }
}

728x90