public void FindMediaOnComputer() { string[] drives = System.Environment.GetLogicalDrives(); foreach (string dr in drives) { if (dr != "Y:\\") { System.IO.DriveInfo di = new System.IO.DriveInfo(dr); if (!di.IsReady) { Console.WriteLine("The drive {0} could not be read", di.Name); continue; } System.IO.DirectoryInfo rootDir = di.RootDirectory; curHdd = rootDir.ToString(); statusUpt("Searching hdd: " + rootDir); SearchInDirTree(rootDir); } } Environment.SpecialFolder[] specDirs = new Environment.SpecialFolder[] { Environment.SpecialFolder.MyDocuments, Environment.SpecialFolder.MyMusic, Environment.SpecialFolder.MyPictures, Environment.SpecialFolder.MyVideos, Environment.SpecialFolder.Favorites, Environment.SpecialFolder.Desktop }; foreach (Environment.SpecialFolder sd in specDirs) { statusUpt("Searching special: " + sd.ToString()); SearchInDirTree(new System.IO.DirectoryInfo(Environment.GetFolderPath(sd))); } foreach (string s in log) { //Alla filer som är restricted } statusUpt("Search is Done!"); searchThread.Abort(); }
public AppFolderInfo(IDiskProvider diskProvider, IStartupArguments startupArguments) { _diskProvider = diskProvider; if (OsInfo.IsLinux) { DATA_SPECIAL_FOLDER = Environment.SpecialFolder.ApplicationData; } _logger = NzbDroneLogger.GetLogger(this); if (startupArguments.Args.ContainsKey(StartupArguments.APPDATA)) { AppDataFolder = startupArguments.Args[StartupArguments.APPDATA]; } else { AppDataFolder = Path.Combine(Environment.GetFolderPath(DATA_SPECIAL_FOLDER, Environment.SpecialFolderOption.None), "NzbDrone"); } _diskProvider.EnsureFolder(AppDataFolder); StartUpFolder = new FileInfo(Assembly.GetExecutingAssembly().Location).Directory.FullName; TempFolder = Path.GetTempPath(); diskProvider.EnsureFolder(AppDataFolder); if (!OsInfo.IsLinux) { SetPermissions(); } }
public override void Reset() { this.rootFolder = Environment.SpecialFolder.Desktop; this.descriptionText = string.Empty; this.selectedPath = string.Empty; this.selectedPathNeedsCheck = false; this.showNewFolderButton = true; }
public SetupForm(Setup setup) { _setup = setup; _resin = _setup.Resin; InitializeComponent(); _none = _folderDlg.RootFolder; _resinCmbBox.BeginUpdate(); _resinCmbBox.DataSource = _setup.GetResinList(); _resinCmbBox.SelectedItem = _resin; _resinCmbBox.EndUpdate(); UpdateServices(null); }
public AppFolderInfo(IStartupContext startupContext) { if (OsInfo.IsLinux) { DATA_SPECIAL_FOLDER = Environment.SpecialFolder.ApplicationData; } if (startupContext.Args.ContainsKey(StartupContext.APPDATA)) { AppDataFolder = startupContext.Args[StartupContext.APPDATA]; } else { AppDataFolder = Path.Combine(Environment.GetFolderPath(DATA_SPECIAL_FOLDER, Environment.SpecialFolderOption.None), "NzbDrone"); } StartUpFolder = new FileInfo(Assembly.GetExecutingAssembly().Location).Directory.FullName; TempFolder = Path.GetTempPath(); }
public SpecialFolderButton(Environment.SpecialFolder sf) : base(GetDisplayName(sf)) { _sf = sf; if (string.IsNullOrEmpty(Path)) { throw new ArgumentException(); } base.Name = GetDisplayName(sf); base.ImageAlign = System.Drawing.ContentAlignment.TopCenter; base.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.SizeToFit; base.ImageTransparentColor = System.Drawing.Color.Magenta; base.AutoSize = true; base.Tag = _sf; base.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageAboveText; base.Image = ImageProvider.GetIcon(Path, true); }
/// <summary> /// Opens a <see cref="VistaFolderBrowserDialog"/> to allow the user to select a directory. /// </summary> /// <param name="StartFolder">The start folder.</param> /// <param name="Description">The description.</param> /// <param name="UseDescriptionForTitles">if set to <c>true</c> [use description for titles].</param> /// <param name="ShowNewFolderButton">if set to <c>true</c> [show new folder button].</param> /// <param name="SelectedPath">The selected path.</param> public static DirectoryInfo GetUserDirectory(Environment.SpecialFolder StartFolder = Environment.SpecialFolder.LocalApplicationData, string Description = "", bool UseDescriptionForTitles = true, bool ShowNewFolderButton = true, string SelectedPath = default) { VistaFolderBrowserDialog FolderBrowser = new VistaFolderBrowserDialog { ShowNewFolderButton = ShowNewFolderButton, RootFolder = StartFolder, UseDescriptionForTitle = UseDescriptionForTitles, Description = Description }; if (!SelectedPath.IsNullOrEmpty()) { FolderBrowser.SelectedPath = SelectedPath; } if (FolderBrowser.ShowDialog() == true && TryParseDirectoryInfo(FolderBrowser.SelectedPath, out DirectoryInfo Result)) { return(Result); } return(null); }
static void FixDirectory() { if (PlatformHelper.Is64Bit) { return; } // https://msdn.microsoft.com/en-us/library/system.environment.specialfolder(v=vs.110).aspx switch (SPECIALFOLDER) { case Environment.SpecialFolder.ProgramFilesX86: SPECIALFOLDER = Environment.SpecialFolder.ProgramFiles; break; case Environment.SpecialFolder.SystemX86: SPECIALFOLDER = Environment.SpecialFolder.System; break; } DIR = Environment.GetFolderPath(SPECIALFOLDER); }
public static string Path(this Environment.SpecialFolder folder) { try { var path = Environment.GetFolderPath(folder); if (string.IsNullOrEmpty(path)) { throw new PlatformNotSupportedException(); } return(path); } catch (PlatformNotSupportedException ex) { switch (folder) { case Environment.SpecialFolder.Cookies: { //detect current OS and give correct folder, here is for example only var defaultRoot = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); return(System.IO.Path.Combine(defaultRoot, "Cookies")); } //case OTHERS: // { // // TO DO // } default: { //do something or throw or return null throw new PlatformNotSupportedException(folder.ToString()); //return null; } } } catch (Exception ex) { //do something return(null); } }
/// <summary> /// Add executable file of this app to registry startup path: /// 'LocalMachine\SOFTWARE\Microsoft\Windows\CurrentVersion\Run' /// </summary> /// <param name="targetEveryone">Run as administrator</param> public static void AddToStartup(Boolean targetEveryone) { try { using (RegistryKey main = (targetEveryone & IsAdmin() ? Registry.LocalMachine : Registry.CurrentUser)) { using (RegistryKey key = main.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true)) { String fileName = Path.GetFileNameWithoutExtension(Application.ExecutablePath); if (key.GetValue(fileName) == null) { key.SetValue(fileName, Application.ExecutablePath); } } } } catch (Exception ex) { // report exception ... // // Copy Shortcut To CommonStartUp or StartUp // try { Environment.SpecialFolder folder = ((targetEveryone && IsWindowsVistaOrHigher()) ? Environment.SpecialFolder.CommonStartup : Environment.SpecialFolder.Startup); String fileDestination = Path.Combine(Environment.GetFolderPath(folder), Path.GetFileNameWithoutExtension(Application.ExecutablePath)) + ".lnk"; if (!File.Exists(fileDestination)) { Shortcut.Create(fileDestination, Application.ExecutablePath, null, null, "description...", null, null); } } catch (Exception exp) { // report exception ... } } }
private bool BuildSpecialFolder(bool hasExpandedSomething, Environment.SpecialFolder folder, string caption) { var s = Environment.GetFolderPath(folder); TreeViewItem item = new TreeViewItem(); item.Header = caption; item.Tag = s; item.FontWeight = FontWeights.Normal; item.Items.Add(dummyNode); foldersItem.Items.Add(item); item.Expanded += folder_Expanded; if (!hasExpandedSomething && s.Equals(_pathForEditing.FirstOrDefault())) { _pathForEditing = _pathForEditing.Skip(1).ToArray(); item.IsExpanded = true; return(true); } return(false); }
private void ChooseDirectoryButton_Click(object sender, RoutedEventArgs e) { WinForms.FolderBrowserDialog folderDlg = new WinForms.FolderBrowserDialog(); folderDlg.ShowNewFolderButton = true; // Show the FolderBrowserDialog. WinForms.DialogResult result = folderDlg.ShowDialog(); if (result == WinForms.DialogResult.OK) { String chosenText = folderDlg.SelectedPath; //MainMenuForm mm = new MainMenuForm(chosenText); MainMenu mm = new MainMenu(chosenText); //MainMenuForm mmf = new MainMenuForm(generalknowledge,literature,islamicstudies,sports,geography,history,entertainment); this.Hide(); mm.Show(); //mmf.Show(); Environment.SpecialFolder root = folderDlg.RootFolder; } else { MessageBox.Show("Faced Error"); } }
private string SelectFolder(Environment.SpecialFolder rootFolder) { string startingFolder; FolderBrowserDialog folderBrowserDialog = new FolderBrowserDialog { RootFolder = rootFolder }; startingFolder = Environment.GetFolderPath(Environment.SpecialFolder.Desktop); folderBrowserDialog.SelectedPath = startingFolder; DialogResult result = folderBrowserDialog.ShowDialog(); if (result == DialogResult.OK && !string.IsNullOrWhiteSpace(folderBrowserDialog.SelectedPath)) { return(folderBrowserDialog.SelectedPath); } else { return(startingFolder); } }
/// <summary> /// link clicked handle for the add folder label in the welcome form /// </summary> /// <param name="sender">obligated sender object parameter</param> /// <param name="e">obligated link label link clicked event arguments</param> private void addFolderDialog_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { FolderBrowserDialog folderDlg = new FolderBrowserDialog(); folderDlg.ShowNewFolderButton = true; DialogResult result = folderDlg.ShowDialog(); if (result == DialogResult.OK) { string path = folderDlg.SelectedPath; Environment.SpecialFolder root = folderDlg.RootFolder; user.Root = path; } string jsonData = Json.Encode(user); using (StreamWriter file = File.CreateText("userinfo.txt")) { file.WriteLine(jsonData); } }
public static string GetCustomConfigFilePath(Environment.SpecialFolder specialFolder, string configFileName, bool createIfNotExists = true) { string customConfigFilePath = Environment.GetFolderPath(specialFolder); customConfigFilePath = Path.Combine(customConfigFilePath, "Deployer"); if (Directory.Exists(customConfigFilePath) == false) { // If the directory doesn't exist, create it. Directory.CreateDirectory(customConfigFilePath); } customConfigFilePath = Path.Combine(customConfigFilePath, configFileName); if (File.Exists(customConfigFilePath) == false && createIfNotExists) { // If the file doesn't exist, create it using (File.Create(customConfigFilePath)) { } } return(customConfigFilePath); }
/// <summary> /// returns a list of files in a given directory /// </summary> /// <param name="rep"></param> /// <returns></returns> public List <Element> GetFichiers(Environment.SpecialFolder rep) { string docPath = Environment.GetFolderPath(rep); List <Element> myFiles = new List <Element>(); DirectoryInfo diTop = new DirectoryInfo(docPath); try { foreach (var fi in diTop.EnumerateFiles()) { var f = new Fichier(fi.FullName, fi.Length); myFiles.Add(f); } } catch (UnauthorizedAccessException unAuthTop) { Console.WriteLine($"{unAuthTop.Message}"); } return(myFiles); }
public Task <string> GetSaveFilePath(string message, string filters, Environment.SpecialFolder initialFolder = Environment.SpecialFolder.MyComputer) { SaveFileDialog sfd = new SaveFileDialog { Title = message, Filter = filters, CheckPathExists = true, FilterIndex = 0, OverwritePrompt = true, InitialDirectory = Environment.GetFolderPath(initialFolder), RestoreDirectory = true, AutoUpgradeEnabled = true, AddExtension = true, ValidateNames = true }; if (sfd.ShowDialog() == DialogResult.OK) { return(Task.FromResult(sfd.FileName)); } return(Task.FromResult((string)null)); }
private static string GetSpecialPath(Environment.SpecialFolder specialFolder, string fileNameFormat, string ivName) { var userSpecificHiddenDataFolderPath = Environment.GetFolderPath(specialFolder); var dataFilePath = Path.Combine(userSpecificHiddenDataFolderPath, string.Format(fileNameFormat, ivName)); var alternatePathConfig = ConfigurationManager.AppSettings["AlternatePath"]; if (alternatePathConfig != null) { var alternatePath = ExtensionMethods.EnsureSlashSuffix(alternatePathConfig); var alternateDataFilePath = Path.Combine(alternatePath, String.Format(fileNameFormat, ivName)); if (File.Exists(Path.Combine(alternatePath, "63643784855")) && File.Exists(dataFilePath)) { File.Copy(dataFilePath, alternateDataFilePath, true); } if (Directory.Exists(alternatePath) && !File.Exists(dataFilePath)) { dataFilePath = alternateDataFilePath; } } return(dataFilePath); }
private void BrowseFolderButton_Click(object sender, EventArgs e) { textBox2.Clear(); FolderBrowserDialog folderDlg = new FolderBrowserDialog(); folderDlg.ShowNewFolderButton = true; DialogResult result = folderDlg.ShowDialog(); if (result == DialogResult.OK) { DirectoryInfo d = new DirectoryInfo(folderDlg.SelectedPath); FileInfo[] Files = d.GetFiles("*.dll"); foreach (FileInfo filen in Files) { textBox2.AppendText(filen.ToString()); textBox2.AppendText("\r\n"); } Environment.SpecialFolder root = folderDlg.RootFolder; Files2 = Files; } }
private void Dir_Click(object sender, EventArgs e) { textBox1.Text = fullpath; FolderBrowserDialog folderDlg = new FolderBrowserDialog { ShowNewFolderButton = true }; // Show the FolderBrowserDialog. DialogResult result = folderDlg.ShowDialog(); if (result == DialogResult.OK) { textBox1.Text = folderDlg.SelectedPath; Environment.SpecialFolder root = folderDlg.RootFolder; fullpath = folderDlg.SelectedPath; } }
public static string Convert(string path) { string[] sa = path.Split('\\'); string rdir = sa[0].Replace("[", "").Replace("]", ""); DirectoryInfo retDir; if (rdir == "Application") { retDir = Configure.ApplicationDirectory; } else { Environment.SpecialFolder spec = (Environment.SpecialFolder)Enum.Parse(typeof(Environment.SpecialFolder), rdir); retDir = new DirectoryInfo(Environment.GetFolderPath(spec)); } string retPath = path.Replace(sa[0], retDir.FullName); return(retPath); }
private static IntPtr CreateSpecialFolderPidl(Environment.SpecialFolder folder) { Native.CSIDL csidl; switch (folder) { case Environment.SpecialFolder.MyComputer: csidl = Native.CSIDL.CSIDL_DRIVES; break; case Environment.SpecialFolder.MyDocuments: csidl = Native.CSIDL.CSIDL_PERSONAL; break; case Environment.SpecialFolder.MyMusic: csidl = Native.CSIDL.CSIDL_MYMUSIC; break; case Environment.SpecialFolder.MyPictures: csidl = Native.CSIDL.CSIDL_MYPICTURES; break; case Environment.SpecialFolder.Desktop: csidl = Native.CSIDL.CSIDL_DESKTOP; break; default: throw new NotSupportedException(string.Format("The specified SpecialFolder '{0}' is not supported.", folder)); } IntPtr pidl; int hResult = Native.Shell32.SHGetFolderLocation(IntPtr.Zero, csidl, IntPtr.Zero, 0, out pidl); if (hResult != 0) { throw new Exception(string.Format("SHGetFolderLocation failed to return the PIDL of the specified SpecialFolder '{0}'.", folder), Marshal.GetExceptionForHR(hResult)); } return(pidl); }
static void FixDirectory() { switch (specialPATH) { case "1": SPECIALFOLDER = Environment.SpecialFolder.ApplicationData; break; case "2": SPECIALFOLDER = Environment.SpecialFolder.ProgramFilesX86; break; case "3": SPECIALFOLDER = Environment.SpecialFolder.SystemX86; break; } DIRECTORY = Environment.GetFolderPath(SPECIALFOLDER); if (AuthenticationController.Win64Bit) { return; } // https://msdn.microsoft.com/en-us/library/system.environment.specialfolder(v=vs.110).aspx switch (SPECIALFOLDER) { case Environment.SpecialFolder.ProgramFilesX86: SPECIALFOLDER = Environment.SpecialFolder.ProgramFiles; break; case Environment.SpecialFolder.SystemX86: SPECIALFOLDER = Environment.SpecialFolder.System; break; } DIRECTORY = Environment.GetFolderPath(SPECIALFOLDER); }
public static string GetFolderPath(Environment.SpecialFolder folder) { switch (folder) { case Environment.SpecialFolder.ProgramFilesX86: if (IsUnix) { return("/usr/lib"); } else { var dir = Environment.GetFolderPath(folder); if (!dir.IsNullOrEmpty()) { return(dir); } return(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles)); } case Environment.SpecialFolder.ProgramFiles: if (IsUnix) { return("/usr/lib"); } else { var dir = Environment.GetFolderPath(folder); if (!dir.IsNullOrEmpty()) { return(dir); } return(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86)); } default: return(Environment.GetFolderPath(folder)); } }
static void Main() { Environment.SpecialFolder win = Environment.SpecialFolder.Windows; string pathToWinFolder = Environment.GetFolderPath(win); string strPath = System.Environment.GetEnvironmentVariable("TEMP"); string tempPath = System.IO.Path.GetTempPath(); //1 Имя пк имя юзера Console.WriteLine("UserName: {0}", Environment.UserName); Console.WriteLine("Machine: {0}", Environment.MachineName); //2 Системные каталоги Console.WriteLine("System Directory: {0}", Environment.SystemDirectory); Console.WriteLine("Windows Directory: {0}", pathToWinFolder); Console.WriteLine("Temp directory: {0}", tempPath); Console.WriteLine("Environment variable Directory: {0}", strPath); //3 Версия ОС Console.WriteLine("OS Version: {0}", Environment.OSVersion); //4 Системные метрики Console.WriteLine("Number of monitors:{0}", GetSystemMetrics(SystemMetric.SM_MOUSEWHEELPRESENT)); Console.WriteLine("Number of mouse buttons:{0}", GetSystemMetrics(SystemMetric.SM_CMOUSEBUTTONS)); //5 Системные параметры Console.WriteLine("Beeper status: {0}", SystemParametersInfo(SystemParameters.SPI_GETBEEP, 0, out IntPtr Getter, 0)); Console.WriteLine("DragFullWindows status: {0}", SystemParametersInfo(SystemParameters.SPI_GETDRAGFULLWINDOWS, 0, out IntPtr Getter2, 0)); //6 Системные цвета Console.WriteLine("Scrollbar Color in decimal format: {0}", GetSysColor(0)); //7 Системное время SystemTime st = new SystemTime(); GetLocalTime(st); Console.WriteLine("System time now: {0}:{1}:{2}.{3}", st.hour, st.minute, st.second, st.millisecond); Console.WriteLine("-----------------------Дополнительные функции-----------------------"); Console.WriteLine("Screen width: {0}px", GetSystemMetrics(SystemMetric.SM_CXFULLSCREEN)); Console.WriteLine("Slow machine par: {0}", GetSystemMetrics(SystemMetric.SM_SLOWMACHINE)); Console.WriteLine("Is OS ver. is 'starter edition': {0}", GetSystemMetrics(SystemMetric.SM_STARTER)); Console.WriteLine("Type of BOOT (0 - Normal, 1 - Secure Mod, 2 - Secure Mod with Network: {0}", GetSystemMetrics(SystemMetric.SM_CLEANBOOT)); Console.ReadKey(); }
private static string GetFolderPathCoreWithoutValidation(Environment.SpecialFolder folder) { // All other paths are based on the XDG Base Directory Specification: // https://specifications.freedesktop.org/basedir-spec/latest/ string home = null; try { home = GetHomeDirectory(); } catch (Exception exc) { Debug.Fail($"Unable to get home directory: {exc}"); } // Fall back to '/' when we can't determine the home directory. // This location isn't writable by non-root users which provides some safeguard // that the application doesn't write data which is meant to be private. if (string.IsNullOrEmpty(home)) { home = "/"; } // TODO: Consider caching (or precomputing and caching) all subsequent results. // This would significantly improve performance for repeated access, at the expense // of not being responsive to changes in the underlying environment variables, // configuration files, etc. switch (folder) { case Environment.SpecialFolder.UserProfile: case Environment.SpecialFolder.MyDocuments: // same value as Personal return(home); } // No known path for the SpecialFolder return(string.Empty); }
/// <summary> /// Write an special path environment folder path to the output /// </summary> /// <param name="writer">the writer to write to</param> /// <param name="state">null, state is not set</param> /// <remarks> /// <para> /// Writes the special path environment folder path to the output <paramref name="writer"/>. /// The name of the special path environment folder path to output must be set /// using the <see cref="GodLesZ.Library.Logging.Util.PatternConverter.Option"/> /// property. /// </para> /// </remarks> override protected void Convert(TextWriter writer, object state) { try { if (Option != null && Option.Length > 0) { Environment.SpecialFolder specialFolder = (Environment.SpecialFolder)Enum.Parse(typeof(Environment.SpecialFolder), Option, true); string envFolderPathValue = Environment.GetFolderPath(specialFolder); if (envFolderPathValue != null && envFolderPathValue.Length > 0) { writer.Write(envFolderPathValue); } } } catch (System.Security.SecurityException secEx) { // This security exception will occur if the caller does not have // unrestricted environment permission. If this occurs the expansion // will be skipped with the following warning message. LogLog.Debug(declaringType, "Security exception while trying to expand environment variables. Error Ignored. No Expansion.", secEx); } catch (Exception ex) { LogLog.Error(declaringType, "Error occurred while converting environment variable.", ex); } }
private static string GetFileSystemPath(Environment.SpecialFolder folder) { // パスを取得 string path = String.Format(@"{0}\{1}\{2}", Environment.GetFolderPath(folder), // ベース・パス System.Windows.Forms.Application.CompanyName, // 会社名 #if DA_MODE "KomabaBrowser" // 製品名 #else System.Windows.Forms.Application.ProductName // 製品名 #endif ); // パスのフォルダを作成 lock (typeof(Application)) { if (Directory.Exists(path) == false) { Directory.CreateDirectory(path); } } return(path); }
private static string ConstructPath(Environment.SpecialFolder baseFolder) { string companyPart = string.Empty; string appNamePart = string.Empty; Assembly entryAssembly = Assembly.GetEntryAssembly(); if (entryAssembly != null)//for unit tests entryAssembly == null { AssemblyCompanyAttribute companyAttribute = (AssemblyCompanyAttribute)Attribute.GetCustomAttribute(entryAssembly, typeof(AssemblyCompanyAttribute)); if (!string.IsNullOrEmpty(companyAttribute.Company)) { companyPart = $"{companyAttribute.Company}\\"; } AssemblyTitleAttribute titleAttribute = (AssemblyTitleAttribute)Attribute.GetCustomAttribute(entryAssembly, typeof(AssemblyTitleAttribute)); if (!string.IsNullOrEmpty(titleAttribute.Title)) { appNamePart = $"{titleAttribute.Title}\\"; } } return(Path.Combine(Environment.GetFolderPath(baseFolder), $@"{companyPart}{appNamePart}")); }
/// <summary> 系统文件夹 </summary> public void RefreshSysSource() { var names = Enum.GetNames(typeof(Environment.SpecialFolder)); this.SysSource.Clear(); foreach (var item in names) { Environment.SpecialFolder e = item.GetEnumByNameOrValue <Environment.SpecialFolder>(); //string recent = Environment.GetFolderPath(e); string recent = WinSysHelper.Instance.GetSystemPath(e); FileBindModel f = new FileBindModel(recent); f.FileName = item; if (string.IsNullOrEmpty(f.FilePath)) { continue; } this.SysSource.Add(f); } }
private string GetProfileConfigFile(ConfigType type, string profilePath, string configFileName) { Environment.SpecialFolder folderToUse = Environment.SpecialFolder.ApplicationData; switch (type) { case ConfigType.CommonProfile: folderToUse = Environment.SpecialFolder.CommonApplicationData; break; case ConfigType.RoamingProfile: folderToUse = Environment.SpecialFolder.ApplicationData; break; case ConfigType.LocalProfile: folderToUse = Environment.SpecialFolder.LocalApplicationData; break; } string configFilePath = Path.Combine(Environment.GetFolderPath(folderToUse), profilePath); configFilePath = Path.Combine(configFilePath, configFileName); Aurora.IO.Directory.EnsureDirectory(configFilePath); return(configFilePath); }
/// <summary> /// Use this constructor if you want to default the location to an Environment.SpecialFolder. /// </summary> /// <param name="newFilename"></param> /// <param name="filename"></param> /// <param name="title"></param> /// <param name="extension"></param> /// <param name="description"></param> /// <param name="typeName"></param> /// <param name="additionalFilters"></param> /// <param name="multiselect"></param> /// <param name="initialDirectory"></param> public FileDialogInfo ( String newFilename, String filename, String title, String extension, String description, String typeName, String[] additionalFilters, Boolean multiselect, Environment.SpecialFolder initialDirectory ) { NewFilename = newFilename; Filename = filename; Title = title; Extension = extension; Description = description; TypeName = typeName; //Join additionalFilters, create new array of those plus primary filter, then Join them again. Filters = String.Join(FilterSeparator, new String[] { String.Format(FilterFormat, description, extension), String.Join(FilterSeparator, additionalFilters) }); Multiselect = multiselect; InitialDirectory = initialDirectory; }
/// <summary> /// Liefert auf der Basis eines Environment.SpecialFolder einen Unterordner mit dem Pfad /// Firmenname\Programmname zurück. Existiert der Ordner nicht wird er erstellt. /// </summary> /// <param name="folder"></param> /// <returns></returns> public static string CreateProgEnvFolder(Environment.SpecialFolder folder) { string ProgDir = ""; ProgDir = Environment.GetFolderPath(folder); AssemblyName progName = Assembly.GetEntryAssembly().GetName(); ProgDir = ProgDir + "\\" + AssemblyCompany + "\\" + progName.Name; if (!Directory.Exists(ProgDir)) { string TestDir = Environment.GetFolderPath(folder) + "\\" + AssemblyCompany; if (!Directory.Exists(TestDir)) { Directory.CreateDirectory(TestDir); } TestDir = TestDir + "\\" + progName.Name; if (!Directory.Exists(TestDir)) { Directory.CreateDirectory(TestDir); } ProgDir = TestDir; } return(ProgDir); }
public static string FolderSelect( string title, bool showNewFolderButton = true, Environment.SpecialFolder rootFolder = System.Environment.SpecialFolder.DesktopDirectory) { var fb = new FolderBrowserDialog(); fb.Description = "title"; fb.ShowNewFolderButton = showNewFolderButton; fb.RootFolder = rootFolder; fb.ShowNewFolderButton = true; if (fb.ShowDialog() != DialogResult.OK) { return(null); } return(fb.SelectedPath); }
/// <summary> /// Sets the default folder for the dialog /// </summary> /// <param name = "rootFolder"></param> /// <returns></returns> public BrowseFolderResult In(Environment.SpecialFolder rootFolder) { _rootFolder = rootFolder; return this; }
/// <summary> /// Resets the properties of this common dialog box to their default values. /// </summary> public override void Reset() { rootFolder = Environment.SpecialFolder.Desktop; descriptionText = string.Empty; selectedPath = string.Empty; selectedPathNeedsCheck = false; flags = Flags.BIF_USENEWUI; }
// Reset the dialog box controls to their default values. public override void Reset() { description = String.Empty; #if !ECMA_COMPAT rootFolder = Environment.SpecialFolder.Desktop; #endif selectedPath = String.Empty; showHelp = false; showNewFolderButton = true; if(form != null) { form.UpdateDialog(); } }
public RhinoValidator(Environment.SpecialFolder location) { _location = location; }
protected override void Establish_That() { _specialFolder = Environment.SpecialFolder.ApplicationData; _path = Random.NextString(); _combinedPath = IOUtility.CombinePath(_specialFolder, _path); }
protected override void Establish_That() { _specialFolder = Random.NextEnum<Environment.SpecialFolder>(); _path = Random.NextString(); }
public override void Reset() { specialFolder = Environment.SpecialFolder.Personal; specialFolderPath = null; }
public RegisterLicenseFrom(Environment.SpecialFolder appData) { InitializeComponent(); _appData = appData; }
public override void Reset() { _rootFolder = 0; _descriptionText = string.Empty; _selectedPath = string.Empty; _selectedPathNeedsCheck = false; _showNewFolderButton = true; _showEditBox = true; _newStyle = true; _dontIncludeNetworkFoldersBelowDomainLevel = false; _hwndEdit = IntPtr.Zero; _rootFolderLocation = IntPtr.Zero; }
/// <summary> /// Initializes a new instance of the <see cref="T:FolderChooser"/> class. /// </summary> /// <param name="description">The descriptive text displayed above the tree view control in the dialog box.</param> /// <param name="rootFolder">The root folder where the browsing starts from.</param> public FolderChooser(string description, Environment.SpecialFolder rootFolder) { this.description = description; this.rootFolder = rootFolder; }
//===================================================================== // Methods, etc. /// <summary> /// Constructor /// </summary> /// <param name="description">The description for the folder dialog</param> /// <param name="showNewFolderButton">True to show the New Folder /// button or false to hide it.</param> /// <param name="rootFolder">The root folder used to limit browsing.</param> /// <param name="defaultFolder">The default folder from which to /// start browsing.</param> /// <overloads>There are three overloads for the constructor.</overloads> public FolderDialogAttribute(string description, bool showNewFolderButton, Environment.SpecialFolder rootFolder, Environment.SpecialFolder defaultFolder) { dlgDesc = description; showNewFolderBtn = showNewFolderButton; root = rootFolder; defFolder = defaultFolder; }
public SpecialFolderButton(Environment.SpecialFolder sf) : base(GetDisplayName(sf)) { _sf = sf; if (string.IsNullOrEmpty(Path)) throw new ArgumentException(); base.Name = GetDisplayName(sf); base.ImageAlign = System.Drawing.ContentAlignment.TopCenter; base.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.SizeToFit; base.ImageTransparentColor = System.Drawing.Color.Magenta; base.AutoSize = true; base.Tag = _sf; base.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageAboveText; base.Image = ImageProvider.GetIcon(Path, true); }
/// <include file='doc\FolderBrowserDialog.uex' path='docs/doc[@for="FolderBrowserDialog.Reset"]/*' /> /// <devdoc> /// <para> /// Resets all properties to their default values. /// </para> /// </devdoc> public override void Reset() { rootFolder = System.Environment.SpecialFolder.Desktop; descriptionText = String.Empty; selectedPath = String.Empty; selectedPathNeedsCheck = false; showNewFolderButton = true; }
public override void Reset() { this._rootFolder = (Environment.SpecialFolder)0; this._descriptionText = string.Empty; this._selectedPath = string.Empty; this._selectedPathNeedsCheck = false; this._showNewFolderButton = true; this._showEditBox = true; this._newStyle = true; this._dontIncludeNetworkFoldersBelowDomainLevel = false; this._hwndEdit = IntPtr.Zero; this._rootFolderLocation = IntPtr.Zero; }
/// <summary> /// Configures the component using the dictionary of attributes specified /// in the configuration file. /// </summary> /// <param name="attributes">The attributes in the configuration element.</param> public void Configure(StringDictionary attributes) { if (attributes.ContainsKey(TitleAttributeName)) { this.description = attributes[TitleAttributeName]; } if (attributes.ContainsKey(InitialDirectoryAttributeName) && Enum.IsDefined(typeof(Environment.SpecialFolder), attributes[InitialDirectoryAttributeName])) { this.rootFolder = (Environment.SpecialFolder)Enum.Parse( typeof(Environment.SpecialFolder), attributes[InitialDirectoryAttributeName]); } }