0
ftp를 사용하여 원격 서버에 디렉터리를 만드는이 함수가 있지만 두 가지 방법 중 하나는 두 개의 FtpWebRequests를 확인하는 것입니다 dir이 그것을 생성하기 위해 exitsts를하는지 확인하기 위해), 또는 생성이 실패 할 때 예외를 잡는다.2 쿼리 또는 예외 흐름 제어를 사용하지 않고 FtpWebReqest를 사용하여 폴더 만들기
var address = new Uri(String.Format("ftp://{0}/{1}/{2}",
Properties.Settings.Default.Address,
arg.RemoteServer.Replace('\\', '_'),
ClinicFolder(arg))); //ClinicFolder(arg) is the directory that may or may not exists.
FtpWebRequest request;
request = (FtpWebRequest)FtpWebRequest.Create(address);
request.Credentials = MyCreds
request.UsePassive = true;
request.UseBinary = true;
request.KeepAlive = keepAlive;
request.Proxy = null;
request.Method = WebRequestMethods.Ftp.MakeDirectory;
try
{
request.GetResponse();
}
catch (WebException e)
{
if (e.Message != "The remote server returned an error: (550) File unavailable (e.g., file not found, no access).")
throw;
}
내가 샤워를 내가 쓴 보면 지금까지 시간을내어 같은 느낌하지만 나열하는 디렉토리를하고 그것을 구문 분석하는 데 훨씬 더 많은 코드를 취할 것 (내가 더 많은 시간을 생각하지만, 내가 프로파일하지 않은).
예외 흐름 제어가 최상의 옵션 인 경우는 드문 경우입니까?