-
* 파일 존재확인.
bool System.IO.File.Exists("filename");
* 파일 이동.
System.IO.File.Move("src", "dsc");
* 파일 이동.
FileInfo fi = new FileInfo("fn");
fi.MoveTo("fn2"); //이름 변경
fi.Delete(); //삭제
* 파일 목록.
DirectoryInfo di = new DirectoryInfo("C:\\test\\");
FileInfo [] fa = di.GetFiles();
foreach(FileInfo fi in fa) { fi.Name; }
* 도스명령.
StreamWriter DosWriter;
StreamReader DosRedaer;
StreamReader ErrorReader;
//프로세스 생성, 초기화
Process DosPr = new Process();
ProcessStartInfo psi = new ProcessStartInfo("cmd");
psi.UseShellExecute = false;
psi.RedirectStandardInput = true;
psi.RedirectStandardOutput = true;
psi.RedirectStandardError = true;
psi.CreateNoWindow = true;
//명령 실행
DosPr.StartInfo = psi;
DosPr.Start();
DosWriter = DosPr.StandardInput;
DosRedaer = DosPr.StandardOutput;
ErrorReader = DosPr.StandardError;
DosWriter.AutoFlush = true;
DosWriter.WriteLine("rename " + oldname + ' ' + System.IO.Path.GetFileName(newname));
DosWriter.Close();
Console.WriteLine(DosRedaer.ReadToEnd());
Console.WriteLine(ErrorReader.ReadToEnd());