public void MoveFile(string fromVirtualPath, string destinationVirtualPath) { CopyFile(fromVirtualPath, destinationVirtualPath); DeleteFile(fromVirtualPath); if (FileMoved != null) { FileMoved.Invoke(this, new FileEventArgs(FixPathForN2(fromVirtualPath), FixPathForN2(destinationVirtualPath))); } }
public void MoveFile(string fromVirtualPath, string destinationVirtualPath) { MoveFileInternal(fromVirtualPath, destinationVirtualPath); if (FileMoved != null) { FileMoved.Invoke(this, new FileEventArgs(destinationVirtualPath, fromVirtualPath)); } }
public void MoveFile(string fromVirtualPath, string destinationVirtualPath) { // TODO: check if this works for move isp.RenameFile(ToRelative(fromVirtualPath), ToRelative(destinationVirtualPath)); if (FileMoved != null) { FileMoved.Invoke(this, new FileEventArgs(destinationVirtualPath, fromVirtualPath)); } }
/// <summary>Moves a file to a new location.</summary> /// <param name="fromVirtualPath">The file path where the file is located.</param> /// <param name="destinationVirtualPath">The path the file should assume after beeing moved.</param> public virtual void MoveFile(string fromVirtualPath, string destinationVirtualPath) { string fromPath = MapPath(fromVirtualPath); string toPath = MapPath(destinationVirtualPath); File.Move(fromPath, toPath); if (FileMoved != null) { FileMoved.Invoke(this, new FileEventArgs(destinationVirtualPath, fromVirtualPath)); } }
private void processMovedDirectoryRecursively(DirectoryEntry <Metadata> directory) { if (_scannedDirectory == directory) { _interruptScanningDirectory = true; } foreach (var file in directory.Files.Values) { FileMoved?.Invoke(this, file); } foreach (var subdirectory in directory.Directories.Values) { processMovedDirectoryRecursively(subdirectory); } }
public void MoveFile(string fromVirtualPath, string destinationVirtualPath) { var source = FileSystemPath.File(fromVirtualPath); var target = FileSystemPath.File(destinationVirtualPath); using (var trx = Session.BeginTransaction()) { AssertParentExists(target); var file = GetSpecificItem(source); file.Path = target; file.Updated = Utility.CurrentTime(); trx.Commit(); } if (FileMoved != null) { FileMoved.Invoke(this, new FileEventArgs(destinationVirtualPath, fromVirtualPath)); } }
private void processMovedEntry(Entry <Metadata> entry) { ProcessingMovedEntry?.Invoke(this, entry); switch (entry) { case RootEntry <Metadata> _: throw new InvalidOperationException($"processing {entry.GetType()} entry is not supported"); case FileEntry <Metadata> file: FileMoved?.Invoke(this, file); break; case DirectoryEntry <Metadata> directory: processMovedDirectory(directory); break; case UnclassifiedEntry <Metadata> _: break; default: throw new InvalidOperationException($"processing {entry.GetType()} entry is not supported"); } }
protected virtual void OnFileMoved(FileChangedEventArgs e) { FileMoved?.Invoke(this, e); }
private void Apply(FileMoved e) { ParentId = e.NewParentId; UpdatedBy = e.UserId; UpdatedDateTime = e.TimeStamp; }
/// <inheritdoc /> public void Handle(FileMoved e) { _logger.Moved(e.File); }
private void ObjectDetected(object source, FileSystemEventArgs e) { if (File.Exists(e.FullPath)) { FileDetected?.Invoke(e.FullPath); //string destinationDir = _defaultDestinationDir; string destinationDir = _config.DefaultDestinationDir.Dir; bool isAddNumber = true; bool isAddMoveDate = false; //foreach (var rule in _rules) // if (Regex.IsMatch(e.Name, rule.Key)) // destinationDir = rule.Value; foreach (RuleElement rule in _config.Rules) { if (Regex.IsMatch(e.Name, rule.Rule)) { destinationDir = rule.TargetFolder; isAddNumber = rule.IsAddNumber; isAddMoveDate = rule.IsAddMoveDate; } } if (destinationDir.Equals(_config.DefaultDestinationDir.Dir)) { RuleFound?.Invoke(false, e.Name); } else { RuleFound?.Invoke(true, e.Name); } string targetFileName = e.Name; if (isAddMoveDate) { string fileExtension = ""; int fileExtensionIdx = -1; Match match = Regex.Match(e.Name, @"\.[а-я|А-Я|a-z|A-z|0-9]*$"); if (match.Success) { fileExtension = match.Value; fileExtensionIdx = match.Index; } targetFileName = string.Format("{0} {1}{2}", e.Name.Substring(0, fileExtensionIdx), DateTime.Today.ToString("yyyyMMdd"), fileExtension); } string destinationFile = destinationDir + "\\" + targetFileName; if (!File.Exists(destinationFile)) { File.Move(e.FullPath, destinationFile); FileMoved?.Invoke(true, e.FullPath, destinationFile); } else if (isAddNumber) { string fileExtension = ""; int fileExtensionIdx = -1; Match match = Regex.Match(destinationFile, @"\.[а-я|А-Я|a-z|A-z|0-9]*$"); if (match.Success) { fileExtension = match.Value; fileExtensionIdx = match.Index; } int fileIdx = 0; int fileIdxIdx = fileExtensionIdx; string pattern = @"\(\d*\)$"; if (fileExtensionIdx > 0) { match = Regex.Match(destinationFile.Substring(0, fileExtensionIdx), pattern); } else { match = Regex.Match(destinationFile, pattern); } if (match.Success) { fileIdx = Convert.ToInt32(Regex.Replace(match.Value, @"[^\d]+", "")) + 1; fileIdxIdx = match.Index; } while (true) { destinationFile = string.Format("{0} ({1}){2}", destinationFile.Substring(0, fileIdxIdx), fileIdx, fileExtension); if (!File.Exists(destinationFile)) { File.Move(e.FullPath, destinationFile); FileMoved?.Invoke(true, e.FullPath, destinationFile); break; } fileIdx++; } } else { FileMoved?.Invoke(false, e.FullPath, ""); } } }
private void fileMoved(object sender, FileEntry <Metadata> file) { FileMoved?.Invoke(this, file); move(file); }