/// <summary> /// Downloads the manifest file from the web /// </summary> /// <param name="PstrServerUrl"></param> /// <param name="PstrDestPath"></param> /// <returns></returns> private static string DownloadFileFromWeb(string PstrServerUrl, string PstrDestPath) { try { string[] LstrPathParts = PstrServerUrl.Split('/'); string LstrManifestName = LstrPathParts[LstrPathParts.Length - 1]; string LstrInstallFilename = Path.Combine(PstrDestPath, LstrManifestName); Console.WriteLine("Reading manifest file from: " + PstrServerUrl); Console.WriteLine("Writing the manifest file to the install folder: " + LstrInstallFilename); WebRequest LobjRequest = System.Net.HttpWebRequest.Create(PstrServerUrl); using (StreamReader LobjReader = new StreamReader(LobjRequest.GetResponse().GetResponseStream())) { using (StreamWriter LobjWriter = new StreamWriter(LstrInstallFilename)) { LobjWriter.Write(LobjReader.ReadToEnd()); } } return(LstrInstallFilename); } catch (Exception PobjEx) { throw PobjEx.PassException("Unable to download manifest from web."); } }
/// <summary> /// Downloads the file from the local file system or from a /// network location via UNC /// </summary> /// <param name="PstrSrcPath"></param> /// <param name="PstrDestPath"></param> /// <returns></returns> private static string DownloadFile(string PstrSrcPath, string PstrDestPath) { try { FileInfo LobjFile = new FileInfo(PstrSrcPath); string LstrInstallFilename = Path.Combine(PstrDestPath, LobjFile.Name); Console.WriteLine("Reading manifest file from: " + PstrSrcPath); Console.WriteLine("Writing the manifest file to the install folder: " + LstrInstallFilename); LobjFile.CopyTo(LstrInstallFilename, true); return(LstrInstallFilename); } catch (Exception PobjEx) { throw PobjEx.PassException("Unable to download the file."); } }