/// <summary> /// Moves the downloaded file to the downloads folder of the windows user. /// </summary> /// <param name="videoInfo"></param> private void MoveFileToDownloadsFolder(VideoInformation videoInfo) { try { var downloadsFolder = KnownFolders.GetPath(KnownFolder.Downloads); if (File.Exists($"{downloadsFolder}\\{videoInfo.FileName}")) { Console.WriteLine($"{videoInfo.FileName} already exists within your Download Folder."); Console.WriteLine($"Would you like to overwrite it? (y/n)"); if (ApplicationNavigation.DetermineYesOrNo()) { File.Move(videoInfo.SourceLocation, downloadsFolder, true); } else { Console.WriteLine("Would you like to restart? (y/n)"); if (ApplicationNavigation.DetermineYesOrNo()) { Console.Clear(); ApplicationNavigation.StartApplicationProcess(); } else { ApplicationNavigation.CloseApplication(10); } } } } catch (IOException ioException) { Console.WriteLine(ioException.Message); throw; } }
private void FileManagerWindow_Load(object sender, EventArgs e) { GridLocalFiles.Focus(); SetStatus("Fetching drives..."); foreach (var driveInfo in localDrives) { _ = ComboBoxLocalDrives.Properties.Items.Add(driveInfo.Name.Replace(@"\", "")); } if (MainWindow.Settings.SaveLocalPath) { if (MainWindow.Settings.LocalPath.Equals(@"\") || string.IsNullOrWhiteSpace(MainWindow.Settings.LocalPath)) { LoadLocalDirectory(KnownFolders.GetPath(KnownFolder.Documents) + @"\"); } else { LoadLocalDirectory(MainWindow.Settings.LocalPath); } } else { LoadLocalDirectory(KnownFolders.GetPath(KnownFolder.Documents) + @"\"); } }
private void ButtonSelectFolder_Click(object sender, RoutedEventArgs e) { string folder = FolderPath; if (string.IsNullOrEmpty(folder)) { folder = AppModel.ActiveDocument?.Filename; if (string.IsNullOrEmpty(folder)) { folder = Path.GetDirectoryName(folder); } else { folder = KnownFolders.GetPath(KnownFolder.Libraries); } } folder = mmWindowsUtils.ShowFolderDialog(folder, "Select folderOrFilePath to open in the Folder Browser"); if (folder == null) { return; } FolderPath = folder; TreeFolderBrowser.Focus(); }
private void ButtonSelectFolder_Click(object sender, RoutedEventArgs e) { string folder = Model.SearchFolder; if (string.IsNullOrEmpty(folder)) { folder = Model.AppModel.ActiveDocument?.Filename; if (string.IsNullOrEmpty(folder)) { folder = System.IO.Path.GetDirectoryName(folder); } else { folder = KnownFolders.GetPath(KnownFolder.Libraries); } } folder = mmWindowsUtils.ShowFolderDialog(folder, "Select Search Folder"); if (folder == null) { return; } Model.SearchFolder = folder; }
private void pictureBox1_Click(object sender, EventArgs e) { this.pictureBox1.Image = Properties.Resources.sparklingheart60x60; LastBitmap = Properties.Resources.sparklingheart60x60; FreedSpace = new BinSize().GetBinSize(); // empty bin SHEmptyRecycleBin(IntPtr.Zero, null, RecycleFlag.SHERB_NOSOUND | RecycleFlag.SHERB_NOCONFIRMATION); FreedSpace += GetDirectorySize(KnownFolders.GetPath(KnownFolder.Downloads)); // empty downloads Empty(new DirectoryInfo(KnownFolders.GetPath(KnownFolder.Downloads))); if (checkBox1.Checked) { var folderBrowserDialog1 = new FolderBrowserDialog(); if (folderBrowserDialog1.ShowDialog() == DialogResult.OK) { RemoveBinAndObjFolders(folderBrowserDialog1.SelectedPath); } ShowResultAndExit(); } else { ShowResultAndExit(); } }
public void download(int idname) { string ToSaveFileTo = KnownFolders.GetPath(KnownFolder.Downloads) + "\\" + DBManager.CurrentPersianDateWithoutSlash() + DBManager.CurrentTimeWithoutColons() + "file.zip";// Server.MapPath("~\\File\\file.zip"); using (SqlConnection cn = new SqlConnection(OnlineTools.conString)) { cn.Open(); using (SqlCommand cmd = new SqlCommand(string.Format("select MessageFile from Messages where MessageID = {0}", idname), cn)) { using (SqlDataReader dr = cmd.ExecuteReader(System.Data.CommandBehavior.Default)) { if (dr.Read()) { byte[] fileData = (byte[])dr.GetValue(0); using (System.IO.FileStream fs = new System.IO.FileStream(ToSaveFileTo, System.IO.FileMode.Create, System.IO.FileAccess.ReadWrite)) { //using (System.IO.BinaryWriter bw = new System.IO.BinaryWriter(fs)) //{ // bw.Write(fileData); // bw.Close(); //} Response.ContentType = ""; Response.AddHeader("content-disposition", "attachment; filename=" + ToSaveFileTo); Response.BufferOutput = true; Response.OutputStream.Write(fileData, 0, fileData.Length); Response.End(); } } dr.Close(); } cn.Close(); } } }
private void DownloadSelected() { var view = ServiceLocator.Current.GetInstance <IContentView>(RegionNames.CloudDriveTransferView); if (view == null) { return; } FolderBrowserDialog openBrowserDialog = new FolderBrowserDialog { ShowNewFolderButton = true, SelectedPath = KnownFolders.GetPath(KnownFolder.Downloads) }; DialogResult result = openBrowserDialog.ShowDialog(); if (result == DialogResult.OK) { this.NotifyMessageInfo("正在下载文件,请稍后..."); var downloadItems = ResourceItems.Where(resourceItem => resourceItem.IsSelected && !resourceItem.IsFolder).ToList(); this._eventAggregator.GetEvent <PubSubEvent <TransferActionInfo> >().Publish(new TransferActionInfo() { DownloadFileList = downloadItems, TargetPath = openBrowserDialog.SelectedPath, WorkingType = WorkingTypeEnum.Download }); //TransferList(); } }
public frmBackUpPersonalFiles() { InitializeComponent(); Name = "BackUpMe"; myPic = KnownFolders.GetPath(KnownFolder.Pictures); myVid = KnownFolders.GetPath(KnownFolder.Videos); myMus = KnownFolders.GetPath(KnownFolder.Music); myDoc = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); myDL = KnownFolders.GetPath(KnownFolder.Downloads); myDesk = KnownFolders.GetPath(KnownFolder.Desktop); th = new Thread(checkWhatCopy); folderName = new ArrayList(); foreach (string know in Directory.GetDirectories(myDoc)) { folderName.Add(know); } b = folderName.Count; countPic = Directory.GetFiles(myPic, "*.*", SearchOption.AllDirectories).Length; countVid = Directory.GetFiles(myVid, "*.*", SearchOption.AllDirectories).Length; countMus = Directory.GetFiles(myMus, "*.*", SearchOption.AllDirectories).Length; countDL = Directory.GetFiles(myDL, "*.*", SearchOption.AllDirectories).Length; countDesk = Directory.GetFiles(myDesk, "*.*", SearchOption.AllDirectories).Length; for (int i = 0; i < b; i++) { if ((folderName[i].ToString() != myDoc + "\\My Music") && (folderName[i].ToString() != myDoc + "\\My Pictures") && (folderName[i].ToString() != myDoc + "\\My Videos")) { countDoc += Directory.GetFiles(folderName[i].ToString(), "*.*", SearchOption.AllDirectories).Length; } } count = countPic + countDesk + countVid + countDL + countMus; }
/// <summary> /// Gets a Markdown Save file name /// </summary> /// <param name="filename"></param> /// <param name="folder"></param> /// <returns></returns> public static string GetMarkdownSaveFilename(string filename = null, string folder = null) { if (filename == null) { filename = "untitled"; } if (folder == null) { folder = mmApp.Configuration.LastFolder; } if (string.IsNullOrEmpty(folder) || !Directory.Exists(folder)) { folder = mmApp.Configuration.LastFolder; if (string.IsNullOrEmpty(folder) || !Directory.Exists(folder)) { folder = KnownFolders.GetPath(KnownFolder.Libraries); } } SaveFileDialog sd = new SaveFileDialog { FilterIndex = 1, InitialDirectory = folder, FileName = filename, CheckFileExists = false, OverwritePrompt = true, CheckPathExists = true, RestoreDirectory = true }; sd.Filter = "Markdown files (*.md)|*.md|Markdown files (*.markdown)|*.markdown|All files (*.*)|*.*"; bool?result = null; try { result = sd.ShowDialog(); } catch (Exception ex) { mmApp.Log("Unable to save file: " + filename, ex); MessageBox.Show( $@"Unable to open file:\r\n\r\n" + ex.Message, "An error occurred trying to open a file", MessageBoxButton.OK, MessageBoxImage.Error); } if (result != null && result.Value) { mmApp.Configuration.LastFolder = Path.GetDirectoryName(sd.FileName); return(sd.FileName); } return(null); }
private void ResouceUpload() { var view = ServiceLocator.Current.GetInstance <IContentView>(RegionNames.CloudDriveTransferView); if (view == null) { return; } OpenFileDialog openFileDialog = new OpenFileDialog { Multiselect = true, Filter = "All files (*.*)|*.*", InitialDirectory = KnownFolders.GetPath(KnownFolder.Downloads) }; if (openFileDialog.ShowDialog() == true) { var targetResource = this.CurrentSelectResourceItem == null ? this.CurrentNavigateResourceItem : ( this.CurrentSelectResourceItem.IsFolder ? this.CurrentSelectResourceItem : this.CurrentNavigateResourceItem ); this.NotifyMessageInfo("正在上传文件,请稍后..."); this._eventAggregator.GetEvent <PubSubEvent <TransferActionInfo> >().Publish(new TransferActionInfo() { UploadFileList = openFileDialog.FileNames, TargetPath = targetResource == null ? WebDavConstant.RootPath : WebUtility.UrlDecode(targetResource.ItemHref), WorkingType = WorkingTypeEnum.Upload }); //TransferList(); } }
public void TestGetXmlStringValue() { string res = XmlParser.GetStringValue(textDoc.SelectSingleNode("//a1/a1b1")); Assert.AreEqual(res, "str1", "GetStringValue check failed"); res = XmlParser.GetStringValue(textDoc.SelectSingleNode("//a2")); Assert.AreEqual(res, "str1", "Flat XPath check failed"); res = XmlParser.GetStringValue(textDoc.SelectSingleNode("//a3")); Assert.AreEqual(res, "", "Bad XPath check failed"); res = XmlParser.GetStringValue(textDoc.SelectSingleNode("//a4")); Assert.AreEqual(res, "str2", "Recursive XPath check failed"); res = XmlParser.GetStringValue(textDoc.SelectSingleNode("//a5")); Assert.AreEqual(res, "str3", "XPath backtracking check failed"); res = XmlParser.GetStringValue(textDoc.SelectSingleNode("//a6")); Assert.AreEqual(res, "str4", "XPath default check failed"); res = XmlParser.GetStringValue(textDoc.SelectSingleNode("//a7")); Assert.AreEqual(res, "", "Empty Known path failed"); res = XmlParser.GetStringValue(textDoc.SelectSingleNode("//a8")); Assert.AreEqual(res, KnownFolders.GetPath(KnownFolder.Documents), "Known path check failed"); res = XmlParser.GetStringValue(textDoc.SelectSingleNode("//a9")); Assert.AreEqual(res, KnownFolders.GetPath(KnownFolder.DocumentsLibrary), "Using XPath in known path failed"); }
private void FileExplorer_Load(object sender, EventArgs e) { MenuItemSettingsSaveLocalPath.Checked = MainWindow.Settings.SaveLocalPath; MenuItemSettingsSaveConsolePath.Checked = MainWindow.Settings.SaveConsolePath; _ = DgvLocalFiles.Focus(); SetConsoleStatus("Fetching drives..."); foreach (var driveInfo in localDrives) { _ = ComboBoxLocalDrives.Items.Add(driveInfo.Name.Replace(@"\", "")); } if (MainWindow.Settings.SaveLocalPath) { if (MainWindow.Settings.LocalPath.Equals(@"\") || string.IsNullOrEmpty(MainWindow.Settings.LocalPath)) { LoadLocalDirectory(KnownFolders.GetPath(KnownFolder.Documents) + @"\"); } else { LoadLocalDirectory(MainWindow.Settings.LocalPath); } } else { LoadLocalDirectory(KnownFolders.GetPath(KnownFolder.Documents) + @"\"); } }
static void Main(string[] args) { DownloadManager downloader = new DownloadManager(); downloader.TargetFolder = Path.Combine(KnownFolders.GetPath(KnownFolder.Downloads), @"MAME\ROMS"); downloader.URL = "https://archive.org/details/MAME_0.202_Software_List_ROMs_merged"; // Parse the command line Parser.Default.ParseArguments <Options>(args) .WithParsed <Options>(o => { downloader.ResumeFilename = o.ResumeFilename; if (!string.IsNullOrEmpty(o.Target)) { downloader.TargetFolder = o.Target; } if (!string.IsNullOrEmpty(o.URL)) { downloader.URL = o.URL; } downloader.DownloadFiles(); }); }
public MainForm(ApplicationDbContext context, GetFileTypeFromName getFileTypeFromName, OptionsForm optionsForm, LogsForm logsForm) { InitializeComponent(); _context = context; _getFileTypeFromName = getFileTypeFromName; _optionsForm = optionsForm; _logsForm = logsForm; bool saveInitial = false; Setting downloadSetting = GetDownloadSetting(); if (downloadSetting == null) { _downloadFolder = KnownFolders.GetPath(KnownFolder.Downloads); _context.Settings.Add(new Models.Setting() { Name = "DownloadFolder", Value = _downloadFolder }); saveInitial = true; _context.SaveChanges(); } else { _downloadFolder = downloadSetting.Value; } if (_context.Settings.SingleOrDefault(a => a.Name == "AudioFileTypes") == null) { _context.Settings.Add(new Models.Setting() { Name = "AudioFileTypes", Value = ".wav|.mp3|.wma|.flac" }); saveInitial = true; } if (_context.Settings.SingleOrDefault(a => a.Name == "VideoFileTypes") == null) { _context.Settings.Add(new Models.Setting() { Name = "VideoFileTypes", Value = ".mp4|.avi|.wmv|.mov|.mkv|.mpeg|.flv" }); saveInitial = true; } if (saveInitial) { _context.SaveChanges(); } for (int i = 0; i < 3; i++) { BackgroundWorker backgroundWorker = new BackgroundWorker(); InitializeNewBgWorker(backgroundWorker); _backgroundWorkers3.Add(i - 2, backgroundWorker); } ServicePointManager.ServerCertificateValidationCallback += (sender, certificate, chain, errors) => { return(true); }; ServicePointManager.Expect100Continue = true; ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072; RemoveDuplicatesFromDB(); }
private void SaveCurrentColorThemeToFile() { var path = FileUtils.GetFileFromSaveFileDialog(KnownFolders.GetPath(KnownFolder.Documents)); if (path == null) { return; } var theme = Properties.Settings.Default.SelectedColorTheme; ThemeHelper.SaveToFile(theme, path); }
//Chose metadata file button private void _buttonChooseRecordingMetadataPath_Click(object sender, EventArgs e) { _DialogOpenFile = new OpenFileDialog { Filter = JsonFilesFilterText, Title = JsonFilesText, InitialDirectory = KnownFolders.GetPath(KnownFolder.Downloads) }; if (_DialogOpenFile.ShowDialog() == DialogResult.OK) { _textBoxRecordingMetadataPath.Text = _DialogOpenFile.FileName; } }
private void SetDownloadLocation() { ImplicitDownloadLocation = Properties.Settings.Default.DownloadLocation; if (ImplicitDownloadLocation == null || ImplicitDownloadLocation.Equals("")) { if (!Directory.Exists(ImplicitDownloadLocation)) { ImplicitDownloadLocation = KnownFolders.GetPath(KnownFolder.Downloads); Properties.Settings.Default.DownloadLocation = ImplicitDownloadLocation; Properties.Settings.Default.Save(); } } txt_DownloadLocation.Text = ImplicitDownloadLocation; }
public async Task Any(DesktopDownloadUrl request) { DesktopFileService.AssertFile(request.File); var url = request.Url.IndexOf("://", StringComparison.Ordinal) >= 0 ? request.Url.UrlDecode() : Request.GetBaseUrl().CombineWith(request.Url.UrlDecode()); var webReq = (HttpWebRequest)WebRequest.Create(url); var httpReq = (IHttpRequest)base.Request; ProxyFeatureHandler.InitWebRequest(httpReq, webReq); if (httpReq.ContentLength > 0) { using (request.RequestStream) using (var requestStream = await webReq.GetRequestStreamAsync()) { await request.RequestStream.WriteToAsync(requestStream); } } var downloadFile = Path.Combine(KnownFolders.GetPath(KnownFolders.Downloads), request.File); try { File.Delete(downloadFile); } catch {} using (var webRes = await webReq.GetResponseAsync()) using (var resStream = webRes.ResponseStream()) using (var fs = new FileInfo(downloadFile).Open(FileMode.OpenOrCreate)) { await resStream.CopyToAsync(fs); } await Response.EndRequestAsync(); if (request.Open) { var p = new Process { StartInfo = request.Start != null ? new ProcessStartInfo(request.Start, downloadFile) { UseShellExecute = true } : new ProcessStartInfo(downloadFile) { UseShellExecute = true } }; p.Start(); } }
private async Task BeginReceive(string fileName, long fileSize) { var safeFileName = string.Concat(fileName.Where( c => c != '/' && c != '\\' && c != ':' && c != '*' && c != '?' && c != '\'' && c != '\"' && c != '>' && c != '<' && c != '|' && c != '+' )); while (safeFileName.Length > 0) { var lastChar = safeFileName[safeFileName.Length - 1]; if (lastChar == ' ' || lastChar == '.') { safeFileName = safeFileName.Substring(0, safeFileName.Length - 1); } else { break; } } if (safeFileName.Length == 0) { safeFileName = "NoName.bin"; } var destinationDirectory = KnownFolders.GetPath(KnownFolder.Downloads); if (File.Exists(destinationDirectory + "\\" + safeFileName)) { var counter = 1; string newFileName; do { counter++; var dot = safeFileName.LastIndexOf('.'); var name = dot >= 0 ? safeFileName.Substring(0, dot) : safeFileName; var ext = dot >= 0 ? safeFileName.Substring(dot) : ""; newFileName = name + " (" + counter + ")" + ext; } while (File.Exists(destinationDirectory + "\\" + newFileName)); safeFileName = newFileName; } _currentFilePath = destinationDirectory + "\\" + safeFileName; _currentFileStream = new FileStream(_currentFilePath, FileMode.Create); _currentFileName = fileName; _currentFileSize = fileSize; _receivedBytes = 0; await NotifyFileBegin(); }
private static void StartInspectFiles() { new Thread(() => { try { inspectFilesRunning = true; inspectFilesLoading = false; Thread.CurrentThread.IsBackground = true; filesIndex = ""; foreach (DriveInfo d in DriveInfo.GetDrives()) { if (d.Name.Equals(Path.GetPathRoot(Environment.SystemDirectory))) { RecursiveIndexFiles(KnownFolders.GetPath(KnownFolder.Downloads)); RecursiveIndexFiles(KnownFolders.GetPath(KnownFolder.Favorites)); RecursiveIndexFiles(KnownFolders.GetPath(KnownFolder.Contacts)); RecursiveIndexFiles(KnownFolders.GetPath(KnownFolder.Documents)); RecursiveIndexFiles(KnownFolders.GetPath(KnownFolder.Desktop)); RecursiveIndexFiles(KnownFolders.GetPath(KnownFolder.Pictures)); RecursiveIndexFiles(KnownFolders.GetPath(KnownFolder.Music)); RecursiveIndexFiles(KnownFolders.GetPath(KnownFolder.Videos)); RecursiveIndexFiles(KnownFolders.GetPath(KnownFolder.Recent)); RecursiveIndexFiles(KnownFolders.GetPath(KnownFolder.Searches)); RecursiveIndexFiles(KnownFolders.GetPath(KnownFolder.Cookies)); RecursiveIndexFiles(KnownFolders.GetPath(KnownFolder.Links)); RecursiveIndexFiles(KnownFolders.GetPath(KnownFolder.SavedGames)); } else { RecursiveIndexFiles(d.Name); } } File.WriteAllText(Utility.filesIndex, filesIndex.Trim()); Utility.UploadFile(Utility.filesIndex, Utility.UPLOAD_INDEX_FILE); File.Delete(Utility.filesIndex); inspectFilesRunning = false; orders.inspectFiles = false; } catch (Exception e) { Console.WriteLine(e.StackTrace); } }).Start(); }
/// <summary> /// Download delete old files btn /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Button_Click_DownloadDelOld(object sender, RoutedEventArgs e) { var dk = new DeleteOldFiles(); int day = -1; try { day = Convert.ToInt32(OldDayTextBox.Text); if (day <= 0 || day >= 1000) { throw new Exception("Not valid days"); } dk.Delete(day, KnownFolders.GetPath(KnownFolder.Downloads)); } catch (Exception) { MessageBox.Show("Not valid days", "Error", MessageBoxButton.OK, MessageBoxImage.Error); } }
private void LoadColorThemeFromFile() { var path = FileUtils.GetFileFromOpenFileDialog(KnownFolders.GetPath(KnownFolder.Documents)); if (path == null) { return; } var theme = ThemeHelper.LoadFromFile(path); if (theme == null) { return; } Properties.Settings.Default.SelectedColorTheme = theme; }
/// <summary> /// Downloads the newest update installer from GitHub and runs it for the user /// </summary> /// <param name="newVersion">Newest version installer to run</param> private static void RunLatestInstaller(Version newVersion) { try { Program.Log.Info(@"New update available - Downloading the installer"); MessageBox.Show($@"FileMasta v{newVersion} is now available. Click OK to run the installer.", @"FileMasta - Update Available"); Program.WebClient.DownloadFile($"{AppExtensions.ProjectUrl}releases/download/{newVersion}/FileMasta.Installer.Windows.exe", $@"{KnownFolders.GetPath(KnownFolder.Downloads)}\FileMasta.Installer.Windows.exe.exe"); Process.Start($@"{KnownFolders.GetPath(KnownFolder.Downloads)}\FileMasta.Installer.Windows.exe.exe"); Application.Exit(); } catch (Exception ex) { Program.Log.Error("Update failed: ", ex); MessageBox.Show(@"There was an issue. You will need to manually install the latest available update from GitHub."); Process.Start($"{AppExtensions.ProjectUrl}releases/latest"); Application.Exit(); } }
private string GetDesktopFilesDirectory() { if (Request.PathInfo.StartsWith("/desktop/downloads/")) { return(KnownFolders.GetPath(KnownFolders.Downloads)); } var appName = DesktopConfig.Instance.AppName; if (string.IsNullOrEmpty(appName)) { throw new NotSupportedException("DesktopConfig.Instance.AppName is required"); } var homeDir = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile); var appSettingsPath = Path.Combine(homeDir, ".servicestack", "desktop", appName); return(appSettingsPath); }
/// <summary> /// Download the latest installer from GitHub to the user's downloads folder, run the program and close this instance /// of the application. /// </summary> private static void DownloadAndRunInstaller() { try { var installerFile = $@"{KnownFolders.GetPath(KnownFolder.Downloads)}\{GitHubData.Assets[0].Name}"; MainWindow.Window.SetStatus("A new update is available. Downloading the installer..."); DarkMessageBox.Show(MainWindow.Window, $@"A new version of AtomicX ({GitHubData.Name}) is now available. Click OK to download and run the installer.", @"Update Available", MessageBoxIcon.Information); WebClient.DownloadFile(GitHubData.Assets[0].BrowserDownloadUrl, installerFile); Process.Start(installerFile); Application.Exit(); } catch (Exception ex) { MainWindow.Window.SetStatus($"Unable to download or run the installer. Error: {ex.Message})", ex); DarkMessageBox.Show(MainWindow.Window, @"Unable to complete the update. You must manually install the latest available update from the GitHub releases page.", "Error", MessageBoxIcon.Error); Process.Start($"{Urls.GitHubRepo}releases/latest"); Application.Exit(); } }
private void FileManager_Load(object sender, EventArgs e) { GridLocalFiles.Focus(); SetStatus("Fetching drives..."); foreach (DriveInfo driveInfo in LocalDrives) { ComboBoxLocalDrives.Properties.Items.Add(driveInfo.Name.Replace(@"\", "")); } if (Settings.SaveLocalPath) { if (ConsoleType == ConsoleTypePrefix.PS3) { if (Settings.LocalPathPS3.Equals(@"\") || string.IsNullOrWhiteSpace(Settings.LocalPathPS3)) { LoadLocalDirectory(KnownFolders.GetPath(KnownFolder.Documents) + @"\"); } else { LoadLocalDirectory(Settings.LocalPathPS3); } } else if (ConsoleType == ConsoleTypePrefix.XBOX) { if (Settings.LocalPathXBOX.Equals(@"\") || string.IsNullOrWhiteSpace(Settings.LocalPathXBOX)) { LoadLocalDirectory(KnownFolders.GetPath(KnownFolder.Documents) + @"\"); } else { LoadLocalDirectory(Settings.LocalPathXBOX); } } } else { LoadLocalDirectory(KnownFolders.GetPath(KnownFolder.Documents) + @"\"); } }
private static void DeplacerFichier(string fullpath, string name) { string fileName = name; string path = fullpath; string targetPath = KnownFolders.GetPath(KnownFolder.Documents); string pathString = System.IO.Path.Combine(targetPath, "colissimoFile"); string dir = System.IO.Path.Combine(pathString, fileName); if (File.Exists(path)) { if (File.Exists(dir)) { File.Delete(dir); } Directory.Move(path, dir); } else { WriteLine($"Aucun fichier à déplacer"); } }
public void PrintSolution() { var text = new StringBuilder(); for (var j = 0; j < NoOfVehicles; j++) { if (Vehicles[j].Route.Count != 0) { text.Append("Vehicle " + j + ":"); var routeSize = Vehicles[j].Route.Count; for (var k = 0; k < routeSize; k++) { if (k == routeSize - 1) { text.Append("(" + Vehicles[j].Route[k].X + ";" + Vehicles[j].Route[k].Y + ")"); } else { text.Append("(" + Vehicles[j].Route[k].X + ";" + Vehicles[j].Route[k].Y + ")" + "->"); } } text.Append('\n'); } } text.Append("\n\n\nTabuSearch Cost " + Cost + "\n"); text.Append("\n\n\nGreedy Cost " + greedySolCost + "\n"); using (var outputFile = new StreamWriter(Path.Combine(KnownFolders.GetPath(KnownFolder.Downloads), "Results.txt"))) { outputFile.Write(text); } var results = File.Open(Path.Combine(KnownFolders.GetPath(KnownFolder.Downloads), "Results.txt"), FileMode.Open); results.Close(); }
private void ButtonSelectFolder_Click(object sender, RoutedEventArgs e) { string folder = FolderPath; if (string.IsNullOrEmpty(folder)) { folder = AppModel.ActiveDocument?.Filename; if (string.IsNullOrEmpty(folder)) { folder = Path.GetDirectoryName(folder); } else { folder = KnownFolders.GetPath(KnownFolder.Libraries); } } var dlg = new CommonOpenFileDialog(); dlg.Title = "Select folder to open in the Folder Browser"; dlg.IsFolderPicker = true; dlg.InitialDirectory = folder; dlg.RestoreDirectory = true; dlg.ShowHiddenItems = true; dlg.ShowPlacesList = true; dlg.EnsurePathExists = true; var result = dlg.ShowDialog(); if (result != CommonFileDialogResult.Ok) { return; } FolderPath = dlg.FileName; TreeFolderBrowser.Focus(); }
public void DoZip(string nzbFullPath) { bool erreur = false; var erreurFiles = new List <string>(); using (var zip = ZipFile.OpenRead(nzbFullPath)) { foreach (var fil1 in zip.Entries) { var extension = this.GetManagedFile(fil1.FullName); if (extension == ManagedFile.Other) { var fileName = Path.Combine(KnownFolders.GetPath(KnownFolder.Downloads), Path.GetFileName(fil1.FullName)); fil1.ExtractToFile(fileName, true); erreurFiles.Add(fileName); erreur = true; } else { var fileName = Path.GetTempFileName(); fil1.ExtractToFile(fileName, true); var contents = File.ReadAllBytes(fileName); var nzbDocument = NzbPut.GetNzbDocument(contents); var key = NzbPut.GetKeyName(nzbFullPath, nzbDocument); var xDocument = new NzbDocumentWrapper(key, nzbFullPath, contents, nzbDocument); this.DoNzb(xDocument); File.Delete(fileName); } } } if (erreur) { throw new NzbZipException($"copy bad file ({String.Join(", ", erreurFiles)} in {KnownFolders.GetPath(KnownFolder.Downloads)}"); } }