public void UniqueFile_ExistingFilePathWithMaximumPathLength_UniqueFilenameCallsEllpipsisForTooLongPath() { const string dir245Chars = @"C:\ThisIsAVeryLongFileNameBecauseItHasMoreThan150CharactersAndToReachThatIHaveToWriteALotMoreTextThanICanThinkAboutRightNowIfYouReadThisUpToHereIOwnYouALittleSnackAndIStillNeedAFewMoreCharactersLetsSimplyCountOneTwoThreeFourFiveSixSevenEightNine"; const string fileName13Chars = "File12345.pdf"; var pathWrapSafe = new PathWrapSafe(); //Combine adds a "\" so the result is the max path lengh of 260 var tooLongPath = pathWrapSafe.Combine(dir245Chars, fileName13Chars); _file.Exists("").ReturnsForAnyArgs(x => true, x => false); _directory.Exists("").ReturnsForAnyArgs(false); var uniqueFilename = new UniqueFilename(tooLongPath, _directory, _file, _pathUtil); Assert.Throws <PathTooLongException>(() => uniqueFilename.CreateUniqueFileName()); }
public void Apply(Job job) { if (!IsEnabled(job)) { return; } var lastSaveDirectory = _currentSettingsProvider.Settings.ApplicationSettings.LastSaveDirectory; if (string.IsNullOrWhiteSpace(lastSaveDirectory)) { return; } var filename = _pathSafe.GetFileName(job.OutputFilenameTemplate); if (string.IsNullOrWhiteSpace(job.JobInfo.OutputFileParameter)) { job.OutputFilenameTemplate = _pathSafe.Combine(lastSaveDirectory, filename); } }
private bool CheckIfFileExistsElseNotifyUser() { var filePath = _pathSafe.Combine(OutputFolder, OutputFilename); //Do not inform user, if SaveFileDialog already did if (filePath == _latestDialogFilePath) { return(true); } if (!_file.Exists(filePath)) { return(true); } var title = Translation.ConfirmSaveAs.ToUpper(CultureInfo.CurrentCulture); var text = Translation.GetFileAlreadyExists(filePath); var interaction = new MessageInteraction(text, title, MessageOptions.YesNo, MessageIcon.Exclamation); _interactionRequest.Raise(interaction, NotifyFileExistsCallback); return(false); }
private void ComposeOutputFilename() { _job.OutputFilenameTemplate = _pathSafe.Combine(OutputFolder, OutputFilename); }