유니티

유니티 파일/폴더 생성, 삭제, 확인

파란색까마귀 2022. 2. 14. 14:28

2016. 5. 20. 22:27

https://blog.naver.com/nagne2011/220715140804

 

- 25 - Unity - 파일/폴더 생성, 삭제, 확인

using System.IO 을 사용한다. 생성 System.IO.File.Create ( string FilePath ); 삭제 System....

blog.naver.com

using System.IO

을 사용한다.

 

생성

 

 

System.IO.File.Create ( string FilePath );

 

 

삭제

 

System.IO.File.Delete(  string FilePath  );

 

 

체크

 

System.IO.File.Exists(  string FilePath  );

 

 

**폴더 일경우는 FileInfo 대신에 DirectoryInfo 사용한다.

 

 

예시

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
 
using System.IO;
 
public class saveData : MonoBehaviour {
 
    public string strSlot_0;
 
    void Awake()
    {
        strSlot_0 = Application.dataPath + "/saveData/slot_0/saveDataList.xml";
    }
 
    public int CheckSaveSlot_0()
    {
        if (File.Exists(strSlot_0) == false
        {
            return 0;
        } else
            return 1;
    }
 
}
 
cs
728x90