Пример #1
0
        private static void SendDesktopDirectory(RemoteIsolatedStorageFile risf, DirectoryInfo desktopDirInfo, string deviceDirPath, bool cleanDeviceDirectory)
        {
            if (cleanDeviceDirectory)
            {
                try
                {
                    risf.DeleteDirectory(deviceDirPath);
                    risf.CreateDirectory(deviceDirPath);
                }
                catch (Exception ex)
                {
                }
            }

            foreach (FileInfo fileInfo in desktopDirInfo.GetFiles())
            {
                risf.SendFile(fileInfo.FullName, Path.Combine(deviceDirPath, fileInfo.Name), true);
            }

            foreach (DirectoryInfo desktopDirInfo1 in desktopDirInfo.GetDirectories())
            {
                string str = Path.Combine(deviceDirPath, desktopDirInfo1.Name);
                risf.CreateDirectory(str);
                SendDesktopDirectory(risf, desktopDirInfo1, str, false);
            }
        }
        private string RetrieveNetworkInfoFile()
        {
            this.SendStatusUpdate("Waiting for network information file to be written to device.");
            RemoteIsolatedStorageFile storage = null;
            int    retryCount     = 0;
            string remoteFileName = string.Empty;

            while (string.IsNullOrEmpty(remoteFileName) && retryCount < 4)
            {
                // Need sleep here to allow application to launch.
                System.Threading.Thread.Sleep(1000);
                storage = this.browserApplication.GetIsolatedStore(null);
                List <RemoteFileInfo> files = storage.GetDirectoryListing(string.Empty);
                DateTime findTimeout        = DateTime.Now.Add(TimeSpan.FromSeconds(15));
                while (DateTime.Now < findTimeout)
                {
                    foreach (RemoteFileInfo info in files)
                    {
                        if (info.Name.Contains("networkInfo.txt"))
                        {
                            remoteFileName = info.Name;
                            break;
                        }
                    }

                    if (!string.IsNullOrEmpty(remoteFileName))
                    {
                        break;
                    }

                    System.Threading.Thread.Sleep(500);
                    storage = this.browserApplication.GetIsolatedStore(null);
                    files   = storage.GetDirectoryListing(string.Empty);
                }

                retryCount++;
            }

            if (string.IsNullOrEmpty(remoteFileName))
            {
                throw new WindowsPhoneDriverException("Application was installed and launched, but did not write network info file");
            }

            this.SendStatusUpdate("Retrieving network information file from device.");
            string localFile = Path.Combine(Path.GetTempPath(), "networkInfo.txt");

            storage.ReceiveFile("networkInfo.txt", localFile, true);
            storage.DeleteFile("networkInfo.txt");
            return(localFile);
        }
Пример #3
0
        private static void SendDirectory(RemoteIsolatedStorageFile risf, string desktopDirPath)
        {
            desktopDirPath = Path.GetFullPath(desktopDirPath);

            if (!Directory.Exists(desktopDirPath))
            {
                Console.WriteLine("Error: Path '{0}' does not exist.", (object)desktopDirPath);
                throw new DirectoryNotFoundException();
            }
            else
            {
                DirectoryInfo desktopDirInfo = new DirectoryInfo(desktopDirPath);
                SendDesktopDirectory(risf, desktopDirInfo, string.Empty, true);
            }
        }
Пример #4
0
        private static void ReceiveDeviceDirectory(RemoteIsolatedStorageFile risf, string deviceRelativeDir, List <RemoteFileInfo> source, DirectoryInfo target, bool cleanDeviceDirectory)
        {
            if (cleanDeviceDirectory)
            {
                string fullName = target.FullName;
                try
                {
                    if (Directory.Exists(fullName))
                    {
                        target.Delete(true);
                        target = Directory.CreateDirectory(fullName);
                    }
                }
                catch (IOException ex)
                {
                    Console.WriteLine("Error: Unable to create folder on desktop.");
                    throw ex;
                }
            }

            foreach (RemoteFileInfo remoteFileInfo in source)
            {
                if (remoteFileInfo.IsDirectory())
                {
                    string        fileName     = Path.GetFileName(remoteFileInfo.Name);
                    string        str          = deviceRelativeDir + (object)Path.DirectorySeparatorChar + fileName;
                    DirectoryInfo subdirectory = target.CreateSubdirectory(fileName);

                    try
                    {
                        List <RemoteFileInfo> directoryListing = risf.GetDirectoryListing(str);
                        ReceiveDeviceDirectory(risf, str, directoryListing, subdirectory, false);
                    }
                    catch (FileNotFoundException ex)
                    {
                    }
                }
                else
                {
                    string fileName              = Path.GetFileName(remoteFileInfo.Name);
                    string sourceDeviceFilePath  = deviceRelativeDir + (object)Path.DirectorySeparatorChar + fileName;
                    string targetDesktopFilePath = target.FullName + (object)Path.DirectorySeparatorChar + fileName;
                    risf.ReceiveFile(sourceDeviceFilePath, targetDesktopFilePath, true);
                }
            }
        }
Пример #5
0
        /// <summary>
        /// The install.
        /// </summary>
        /// <param name="applicationDefinition">
        /// The application definition.
        /// </param>
        /// <returns>
        /// The <see cref="InstallationResult"/>.
        /// </returns>
        public override InstallationResult Install(ApplicationDefinition applicationDefinition)
        {
            InstallationResult result = base.Install(applicationDefinition);

            RemoteIsolatedStorageFile store = GetIsoStorage(applicationDefinition);

            if (store.FileExists(BddhostFilePath))
            {
                store.DeleteFile(BddhostFilePath);
            }

            string hostName = Dns.GetHostEntry("127.0.0.1").HostName + ":" + this.Port;

            File.WriteAllLines(BddhostFilePath, new[] { hostName });

            store.SendFile(BddhostFilePath, BddhostFilePath, true);

            return(result);
        }
Пример #6
0
        private static void ReceiveDirectory(RemoteIsolatedStorageFile risf, string desktopDirPath)
        {
            if (Path.DirectorySeparatorChar != desktopDirPath[desktopDirPath.Length - 1])
            {
                desktopDirPath = desktopDirPath + (object)Path.DirectorySeparatorChar;
            }

            desktopDirPath = desktopDirPath + "IsolatedStore";
            var target = new DirectoryInfo(desktopDirPath);

            try
            {
                List <RemoteFileInfo> directoryListing = risf.GetDirectoryListing(string.Empty);
                ReceiveDeviceDirectory(risf, string.Empty, directoryListing, target, true);
            }
            catch (FileNotFoundException ex)
            {
                Console.WriteLine("Info: IsolatedStore for this application is empty.");
                throw ex;
            }
        }
        private static void SendDesktopDirectory(RemoteIsolatedStorageFile risf, DirectoryInfo desktopDirInfo, string deviceDirPath, bool cleanDeviceDirectory)
        {
            if (cleanDeviceDirectory)
            {
                try
                {
                    risf.DeleteDirectory(deviceDirPath);
                    risf.CreateDirectory(deviceDirPath);
                }
                catch (Exception ex)
                {
                }
            }
            
            foreach (FileInfo fileInfo in desktopDirInfo.GetFiles())
            {
                risf.SendFile(fileInfo.FullName, Path.Combine(deviceDirPath, fileInfo.Name), true);
            }

            foreach (DirectoryInfo desktopDirInfo1 in desktopDirInfo.GetDirectories())
            {
                string str = Path.Combine(deviceDirPath, desktopDirInfo1.Name);
                risf.CreateDirectory(str);
                SendDesktopDirectory(risf, desktopDirInfo1, str, false);
            }
        }
 private static void SendDirectory(RemoteIsolatedStorageFile risf, string desktopDirPath)
 {
     desktopDirPath = Path.GetFullPath(desktopDirPath);
     
     if (!Directory.Exists(desktopDirPath))
     {
         Console.WriteLine("Error: Path '{0}' does not exist.", (object)desktopDirPath);
         throw new DirectoryNotFoundException();
     }
     else
     {
         DirectoryInfo desktopDirInfo = new DirectoryInfo(desktopDirPath);
         SendDesktopDirectory(risf, desktopDirInfo, string.Empty, true);
     }
 }
        private static void ReceiveDeviceDirectory(RemoteIsolatedStorageFile risf, string deviceRelativeDir, List<RemoteFileInfo> source, DirectoryInfo target, bool cleanDeviceDirectory)
        {
            if (cleanDeviceDirectory)
            {
                string fullName = target.FullName;
                try
                {
                    if (Directory.Exists(fullName))
                    {
                        target.Delete(true);
                        target = Directory.CreateDirectory(fullName);
                    }
                }
                catch (IOException ex)
                {
                    Console.WriteLine("Error: Unable to create folder on desktop.");
                    throw ex;
                }
            }

            foreach (RemoteFileInfo remoteFileInfo in source)
            {
                if (remoteFileInfo.IsDirectory())
                {
                    string fileName = Path.GetFileName(remoteFileInfo.Name);
                    string str = deviceRelativeDir + (object)Path.DirectorySeparatorChar + fileName;
                    DirectoryInfo subdirectory = target.CreateSubdirectory(fileName);
                    
                    try
                    {
                        List<RemoteFileInfo> directoryListing = risf.GetDirectoryListing(str);
                        ReceiveDeviceDirectory(risf, str, directoryListing, subdirectory, false);
                    }
                    catch (FileNotFoundException ex)
                    {
                    }
                }
                else
                {
                    string fileName = Path.GetFileName(remoteFileInfo.Name);
                    string sourceDeviceFilePath = deviceRelativeDir + (object)Path.DirectorySeparatorChar + fileName;
                    string targetDesktopFilePath = target.FullName + (object)Path.DirectorySeparatorChar + fileName;
                    risf.ReceiveFile(sourceDeviceFilePath, targetDesktopFilePath, true);
                }
            }
        }
        private static void ReceiveDirectory(RemoteIsolatedStorageFile risf, string desktopDirPath)
        {
            if (Path.DirectorySeparatorChar != desktopDirPath[desktopDirPath.Length - 1])
            {
                desktopDirPath = desktopDirPath + (object)Path.DirectorySeparatorChar;
            }

            desktopDirPath = desktopDirPath + "IsolatedStore";
            var target = new DirectoryInfo(desktopDirPath);
            try
            {
                List<RemoteFileInfo> directoryListing = risf.GetDirectoryListing(string.Empty);
                ReceiveDeviceDirectory(risf, string.Empty, directoryListing, target, true);
            }
            catch (FileNotFoundException ex)
            {
                Console.WriteLine("Info: IsolatedStore for this application is empty.");
                throw ex;
            }
        }