목록에서 파일 크기를 가져 와서 결과를 텍스트 파일로 출력하려고합니다. 현재 파일을 읽었을 때 파일을 읽었는지 확인하고 콘솔과 텍스트 파일로 출력하면텍스트 파일에서 파일 크기 가져 오기
저는 "이번 주에 시작되었습니다"라는 새로운 프로그래밍입니다. 이것은 쉬운 질문일지도 모르지만 시도하고십시오 그러나 기울어지는 것은 확실히 그것을 작동한다
나는 foreach 반복 안쪽에 이것을 두는 것을 시도하고 경로를 읽는 것을 시도해 그러나 작동하지 않는다. 그것은이 방법을 수행 할 수 없습니다해야하는 이유
DirectoryInfo di = new DirectoryInfo(path);
FileInfo[] fiArr = di.GetFiles();
foreach (FileInfo f in fiArr)
심하게 코드를 사전에 그리고이 경우 내 코드 지금까지
static void Main(string[] args)
{
string[] lines = System.IO.File.ReadAllLines(@"C:\Locations2.txt");
foreach (string path in lines)
if (File.Exists(path))
using (System.IO.StreamWriter file = new System.IO.StreamWriter(@"C:\Results.txt", true))
{
file.WriteLine("File found" + "\t" + path);
Console.WriteLine("File found" + "\t" + path);
}
else
using (System.IO.StreamWriter file = new System.IO.StreamWriter(@"C:\Results.txt", true))
{
file.WriteLine("Does not Exist" + "\t" + path);
Console.WriteLine("Does not Exist" + "\t" + path);
}
}
감사합니다 당신이 조언을 할 수 있습니까?
힌트 : 배치 파일 작성/루프 외부 개방 .... –