FileStream---- 파일 스트림 작업
1670 단어 C#학습
void Start()
{
string path= @"F:\UnityProjects_5.6.4\CSharpStudy\001.txt";
//1.
FileStream fileStream = new FileStream(path,FileMode.Open);
//2.
byte[] data = new byte[1024];
//3. /
while (true)
{
// ,data , data 0 ,data.Length
int length = fileStream.Read(data, 0, data.Length);
if (length==0)
{
Debug.Log(" ");
break;
}
for (int i = 0; i < length; i++)
{
Debug.Log(data[i]);
}
}
//
string path2= @"F:\UnityProjects_5.6.4\CSharpStudy\002.txt";
//
string path3= @"F:\UnityProjects_5.6.4\CSharpStudy\003.txt";
//
// , 002
FileStream readSream = new FileStream(path2,FileMode.Open);
// , 002 003
FileStream writeStream = new FileStream(path3,FileMode.Open);
byte[] data2 = new byte[1024];
while (true)
{
// Read , ,
// 002.txt , data2
int length = readSream.Read(data2,0,data2.Length);
if (length==0)
{
Debug.Log(" ");
break;
}
else
{// Write , ,
// 002.txt 003
writeStream.Write(data2,0,data2.Length);
}
}
}