Fusion.Build.Builder.DownloadIfModified C# (CSharp) Method

DownloadIfModified() private method

http://stackoverflow.com/questions/6239485/httpwebrequest-vs-webclient-special-scenario
private DownloadIfModified ( string url, string fullFilePath ) : bool
url string
fullFilePath string
return bool
		bool DownloadIfModified(string url, string fullFilePath) 
		{            
			try {
				var request = (HttpWebRequest)HttpWebRequest.Create(new Uri(url));

				if (File.Exists(fullFilePath)) {
					request.IfModifiedSince = File.GetLastWriteTimeUtc(fullFilePath);
					request.Method = "GET";
				} else {
					var dirName = Path.GetDirectoryName(fullFilePath);
					if (!Directory.Exists(dirName)) {
						Directory.CreateDirectory(dirName);
					}
				}

				Log.Message("  Request...");
				var response = (HttpWebResponse)request.GetResponse();

				Log.Message("  Writing...");
				using ( var fs = File.OpenWrite(fullFilePath) ) {
					 response.GetResponseStream().CopyTo( fs );
				}

				Log.Message("  Done.");

				return true;
			}
			catch(WebException ex) {
				if (ex.Status != WebExceptionStatus.ProtocolError) {
					throw;
				}

				var response = (HttpWebResponse)ex.Response;
				if (response.StatusCode != HttpStatusCode.NotModified) {
					throw;
				} else {
					Log.Message("  File is up-to-date.");
				}

				return false;    
			}
		}