using System; using System.Collections.Generic; using System.Text; using System.Net; using System.IO; using System.Xml; namespace DarkWynter.App { public class Installer { private static string ftpServer = "ftp://skylark.dreamhost.com/darkwynter.com/Beta2/Trunk/"; private static string userName = "darkwynter"; private static string password = "wynter1"; public Installer() { } /// /// /// /// public static void DownloadContentProjectFile(string file) { // Open the web client and get the content file. WebClient client = new WebClient(); try { client.Credentials = new NetworkCredential(userName, password); client.DownloadFile(ftpServer + new FileInfo(file).Name, file); } catch (WebException we) { // If not connecting to server should init alert box, not fail... Console.WriteLine(we.ToString()); } client.Dispose(); } /// /// Open content.project file and parse for all content filenames. /// Download each file to local client. /// /// Content Project xml is generated by VSEC# and XNA. /// /// Fully qualified path to the "Content.contentproj" file generated by Xna. public static void DownloadContent(string contentProjectPath) { // Read the Xml File try { XmlDocument reader = new XmlDocument(); reader.Load(contentProjectPath); // Unpack the Project Node foreach (XmlNode projectNode in reader.ChildNodes) { if (projectNode.Name == "Project") { // Unpack the Item Node foreach (XmlNode itemNode in projectNode.ChildNodes) { if (itemNode.Name == "ItemGroup") { // Unpack the Compile Node foreach (XmlNode compileNode in itemNode.ChildNodes) { if (compileNode.Name == "Compile") { // Get the file path of the content file string filename = compileNode.Attributes["Include"].Value; // Open the web client and get the content file. WebClient client = new WebClient(); try { client.Credentials = new NetworkCredential(userName, password); client.DownloadFile(ftpServer + "/" + new FileInfo(filename).Name, filename); //client.UploadFile(ftpServer + "/" + new FileInfo(filename).Name, "STOR", filename); } catch (WebException we) { // If not connecting to server should init alert box, not fail... Console.WriteLine(we.ToString()); } client.Dispose(); } } } } } } } catch { System.Diagnostics.Debug.WriteLine("Error reading xml"); throw new Exception("Error reading XML"); } } }// End Installer }// End Namespace } }