internal void CopySourceToRemoteComputer(string rootFolder, string subfolder, string mainFile, List <string> additionalFiles, List <string> additionalFolders) { try { string fullPath = Path.Combine(rootFolder, subfolder); if (NetUse.Mount(string.Empty, rootFolder, Username, Password)) { if (!Directory.Exists(fullPath)) { Directory.CreateDirectory(fullPath); } // Copy of the main file FileInfo mainFileInfo = new FileInfo(mainFile); File.Copy(mainFile, Path.Combine(fullPath, mainFileInfo.Name), true); // Copy of the additional files CopyFiles(additionalFiles, fullPath); // Copy of the additional folders foreach (string folder in additionalFolders) { CopyFolders(folder, fullPath); } } } catch (Exception ex) { throw new CopyFailedException(ex.Message); } }
/// <summary> /// Checks if credential for this computer are valid by trying to connect to C:\Windows. /// </summary> /// <returns>True if the connection succeed, otherwise, false.</returns> internal bool IsCredentialOk() { string rootFolder = @"\\" + ComputerName + @"\C$\Windows"; try { return(NetUse.Mount(string.Empty, rootFolder, Username, Password)); } catch (Exception) { } return(false); }