/// <summary> /// Upload a file /// </summary> /// <param name="from"></param> /// <param name="to"></param> /// <param name="settings">see FTPDestination check for ifExists and removePrepend</param> /// <param name="prepend">Prefix for file (or null)</param> /// <returns>True if uploaded, false if not uploaded because already existing</returns> public bool UploadFile(string from, string to, DestinationFTP settings, string prepend) { if (!File.Exists(from)) { throw new FileNotFoundException("Local file not found", from); } if (settings.actionIfFileExists == DestinationFTP.IfExistsDontTransfer) { if (_client.FileExists(to)) { return(false); } } _client.UploadFile(from, to, FtpExists.Overwrite); RenameIfPrepend(to, prepend); return(true); }
/// <summary> /// Upload a file /// </summary> /// <param name="from"></param> /// <param name="to"></param> /// <param name="settings">see FTPDestination check for ifExists and removePrepend</param> /// /// <param name="prepend">File Prefix or null</param> /// <returns>True if uploaded, false if not uploaded because already existing</returns> public bool UploadFile(string from, string to, DestinationFTP settings, string prepend) { if (!File.Exists(from)) { throw new FileNotFoundException("Local file not found", from); } if (settings.actionIfFileExists == DestinationFTP.IfExistsDontTransfer) { if (_client.Exists(to)) { return(false); } } using (Stream fileStream = File.OpenRead(from)) { _client.UploadFile(fileStream, to, true, null); } RenameIfPrepend(to, prepend); return(true); }