protected virtual void UpdateImageTex(System.Environment.SpecialFolder folder, string filename) { try { var path = GetPath(folder, filename); if (!File.Exists(path)) { ReleaseImageTex(); return; } var writeTime = File.GetLastWriteTime(path); if (writeTime != lastFiletime || path != lastPath) { lastFiletime = writeTime; lastPath = path; if (ImageTex == null) { ImageTex = new Texture2D(2, 2, TextureFormat.ARGB32, true); ImageTex.filterMode = FilterMode.Bilinear; ImageTex.wrapMode = TextureWrapMode.Repeat; ImageTex.anisoLevel = 0; } ImageTex.LoadImage(File.ReadAllBytes(path)); } } catch (System.Exception e) { Debug.LogError(e); } }
private static string ConstructPath(System.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 = string.Format("{0}\\", companyAttribute.Company); } AssemblyTitleAttribute titleAttribute = (AssemblyTitleAttribute)Attribute.GetCustomAttribute(entryAssembly, typeof(AssemblyTitleAttribute)); if (!string.IsNullOrEmpty(titleAttribute.Title)) { appNamePart = string.Format("{0}\\", titleAttribute.Title); } } string backingFilePath = Path.Combine( Environment.GetFolderPath(baseFolder), string.Format(@"{0}{1}tracked_settings.xml", companyPart, appNamePart) ); return(backingFilePath); }
public static string GetApplicationFile(string appTitle, string filename, System.Environment.SpecialFolder folder = System.Environment.SpecialFolder.LocalApplicationData) { var appPath = GetApplicationFolder(appTitle, folder); var fullPath = Path.Combine(appPath, filename); return(fullPath); }
public static string TryGetFolderPath(System.Environment.SpecialFolder folder) { // the .NET function fails, if the path is for example set to e: instead of e:\ string result = string.Empty; try { result = Environment.GetFolderPath(folder); } catch (ArgumentException) { // Not so nice. Let's check the registry ourselves. string folderName = folder.ToString(); try { RegistryKey key = Registry.CurrentUser; key = key.OpenSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders"); if ((key != null) & (key.GetValue(folderName) != null)) { result = key.GetValue(folderName).ToString().TrimEnd('\\'); } } catch (Exception) { // if we can't access registry, we have no choice but to return an empty string } } return(result); }
public string GetFolderPath(System.Environment.SpecialFolder folder, System.Environment.SpecialFolderOption option) { return(this.EncapsulateWithExtension( () => System.Environment.GetFolderPath(folder, option), e => e.BeginGetFolderPath(folder, option), (e, r) => e.EndGetFolderPath(r, folder, option), (IEnvironmentExtension e, ref Exception exception) => e.FailGetFolderPath(ref exception, folder, option))); }
static DataFolder() { System.Environment.SpecialFolder folder = Environment.SpecialFolder.LocalApplicationData; string dir = System.Environment.GetFolderPath(folder, Environment.SpecialFolderOption.DoNotVerify); _path = System.IO.Path.Combine(dir, "Jerome Terry", "Poker Hand History"); }
public static string GetApplicationFolder(string appTitle, System.Environment.SpecialFolder folder = System.Environment.SpecialFolder.LocalApplicationData) { var systemPath = System.Environment.GetFolderPath(folder); var appPath = Path.Combine(systemPath, appTitle); Directory.CreateDirectory(appPath); return(appPath); }
public LocalStorageFile(System.Environment.SpecialFolder folder, string filename = "") { if (string.IsNullOrEmpty(filename)) { filename = GetFilenameByAttribute(this); } Filename = System.IO.Path.Combine(System.Environment.GetFolderPath(folder), filename); }
/// <summary> /// Resets all properties to their default values. /// </summary> public override void Reset() { _description = string.Empty; _useDescriptionForTitle = false; _selectedPath = string.Empty; _rootFolder = Environment.SpecialFolder.Desktop; _showNewFolderButton = true; }
public override void Reset( ) { _rootFolder = Environment.SpecialFolder.Desktop; _rootFolderPath = string.Empty; _description = string.Empty; _selectedPath = string.Empty; _selectedPathNeedCheck = false; _showNewFolderButton = false; }
public FolderPath( FolderSelectionMethod method = FolderSelectionMethod.SpecialFolder, System.Environment.SpecialFolder specialFolder = System.Environment.SpecialFolder.MyDocuments, string folderpath = DEFAULT_FILEPATH) { this.method = method; this.specialFolder = specialFolder; this.folderpath = folderpath; }
public static string GetApplicationFolder(System.Environment.SpecialFolder folder = System.Environment.SpecialFolder.LocalApplicationData) { var assembly = Assembly.GetEntryAssembly() ?? Assembly.GetExecutingAssembly(); var appTitle = assembly.GetCustomAttributes(typeof(AssemblyTitleAttribute), false) .OfType <AssemblyTitleAttribute>() .First() .Title; return(GetApplicationFolder(appTitle, folder)); }
private static void TryAdd(List <Serializable.TreeNode> lst, System.Environment.SpecialFolder folder, string id, string display) { try { TryAdd(lst, System.Environment.GetFolderPath(folder), id, display); } catch { } }
public static bool Load <S>(this System.Environment.SpecialFolder folder, string filename, ref S data) { try { var path = folder.DataPath(filename); JsonUtility.FromJsonOverwrite(File.ReadAllText(path), data); return(true); } catch (System.Exception e) { Debug.Log(e); } return(false); }
public LocalStorageFileAttribute(System.Environment.SpecialFolder folder, string filename = "") { if (string.IsNullOrEmpty(filename)) { Filename = System.IO.Path.Combine(System.Environment.GetFolderPath(folder), System.Windows.Forms.Application.ProductName + ".settings"); } else { Filename = filename; } }
public static bool Save <S>(this System.Environment.SpecialFolder folder, string filename, ref S data) { try { var path = folder.DataPath(filename); File.WriteAllText(path, JsonUtility.ToJson(data, true)); return(true); } catch (System.Exception e) { Debug.Log(e); } return(false); }
public void Update(System.Environment.SpecialFolder folder, string filename) { var tnow = Time.timeSinceLevelLoad; var dt = tnow - lastUpdateTime; if (dt > updateInterval) { lastUpdateTime = tnow; UpdateImageTex(folder, filename); } }
public static string Path(this System.Environment.SpecialFolder This, params string[] SubFolders) { var ret = System.Environment.GetFolderPath(This); foreach (var item in SubFolders) { ret = System.IO.Path.Combine(ret, item); } return(ret); }
public DirectorySelection(System.Environment.SpecialFolder pSpecialFolder, string pSelectedPath, bool pShowNewFolderButton) { this.m_dialog = new FolderBrowserDialog(); this.m_dialog.RootFolder = pSpecialFolder; if (pSelectedPath.Trim() != "") { this.m_dialog.SelectedPath = pSelectedPath; } this.m_dialog.ShowNewFolderButton = pShowNewFolderButton; InitializeUI(); }
public bool Save(System.Environment.SpecialFolder where, System.String name = "") { try { var path = System.Environment.GetFolderPath(where) + "\\" + (name == "" ? System.DateTime.Now.ToString().Replace('-', '_').Replace(':', '_').Replace(' ', '_') : name) + "_eye.bmp"; EyeImage.Save(path); return(true); } catch (System.Exception) { return(false); } }
/// <summary> /// /// </summary> /// <param name="title"></param> /// <param name="environment"></param> /// <param name="path"></param> /// <returns></returns> private string getFolderPath(string title, System.Environment.SpecialFolder environment, string path) { using (FolderBrowserDialog dialog = new FolderBrowserDialog()) { dialog.Description = title; dialog.ShowNewFolderButton = false; dialog.RootFolder = environment; if (dialog.ShowDialog() == DialogResult.OK) { path = dialog.SelectedPath + "\\"; } } return(path); }
public static string GetPath(string title, System.Environment.SpecialFolder initDir = Environment.SpecialFolder.MyPictures) { System.Windows.Forms.FolderBrowserDialog dialog = new System.Windows.Forms.FolderBrowserDialog(); dialog.Description = title; dialog.RootFolder = initDir; if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { return(dialog.SelectedPath); } else { return(null); } }
private static string GetValidPath(System.Environment.SpecialFolder wanted = System.Environment.SpecialFolder.MyDocuments) { string baseFolder = null; baseFolder = System.Environment.GetFolderPath(wanted); if (baseFolder == "") { baseFolder = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal); if (baseFolder == "") { baseFolder = Application.persistentDataPath; } } return(baseFolder); }
static StackObject *GetFolderPath_23(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj) { ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain; StackObject *ptr_of_this_method; StackObject *__ret = ILIntepreter.Minus(__esp, 1); ptr_of_this_method = ILIntepreter.Minus(__esp, 1); System.Environment.SpecialFolder @folder = (System.Environment.SpecialFolder) typeof(System.Environment.SpecialFolder).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); __intp.Free(ptr_of_this_method); var result_of_this_method = System.Environment.GetFolderPath(@folder); return(ILIntepreter.PushObject(__ret, __mStack, result_of_this_method)); }
/// <summary>Retrieves the <see cref="Shell32.KNOWNFOLDERID_Enum"/> associated with the <see cref="Environment.SpecialFolder"/>.</summary> /// <param name="spFolder">The <see cref="Environment.SpecialFolder"/>.</param> /// <returns>Matching <see cref="Shell32.KNOWNFOLDERID_Enum"/>.</returns> public static Shell32.KNOWNFOLDERID_Enum KnownFolderId(this System.Environment.SpecialFolder spFolder) { if (spFolder == Environment.SpecialFolder.Personal) { return(Shell32.KNOWNFOLDERID_Enum.FOLDERID_Documents); } if (spFolder == Environment.SpecialFolder.DesktopDirectory) { return(Shell32.KNOWNFOLDERID_Enum.FOLDERID_Desktop); } foreach (Shell32.KNOWNFOLDERID_Enum val in Enum.GetValues(typeof(Shell32.KNOWNFOLDERID_Enum))) { if (val.SpecialFolder() == spFolder) { return(val); } } throw new InvalidCastException(@"There is not a Known Folder equivalent to this SpecialFolder."); }
static public string GetDir(System.Environment.SpecialFolder special, string start, string info) { string pth = string.Empty; using (FolderBrowserDialog fbd = new FolderBrowserDialog()) { fbd.RootFolder = special; fbd.Description = info; if (start != null) { fbd.SelectedPath = start; } if (fbd.ShowDialog() == DialogResult.OK) { pth = fbd.SelectedPath; } } return(pth); }
/// <summary> /// Adds a system mount that is statically defined at the start of the build. /// </summary> private void AddStaticSystemMount(string name, SpecialFolder specialFolder, bool allowCreateDirectory = false, bool trackSourceFileChanges = false) { string folder = null; try { // Don't verify the path for the sake of performance and also because if the path is verified and doesn't // exist, an empty string will be returned. We want to unconditionally create the mount whether the backing // path exists or not. folder = SpecialFolderUtilities.GetFolderPath(specialFolder, SpecialFolderOption.DoNotVerify); } catch (ArgumentException) { Logger.Log.CouldNotAddSystemMount(m_loggingContext, name, folder); return; } AddStaticSystemMount(name, folder, allowCreateDirectory, trackSourceFileChanges); }
/// <summary> /// Gets the path to the system special folder that is identified by the specified enumeration. /// </summary> /// <param name="folder">An enumerated constant that identifies a system special folder.</param> /// <param name="option">Specifies options to use for accessing a special folder.</param> /// <returns>The path to the specified system special folder, if that folder physically exists /// on your computer; otherwise, an empty string ("")</returns> public static string GetFolderPath(SpecialFolder folder, SpecialFolderOption option = SpecialFolderOption.None) { // check if there is profile redirect if (s_envVars != null) { string envVar = null; switch (folder) { case SpecialFolder.InternetCache: envVar = "INTERNETCACHE"; break; case SpecialFolder.History: envVar = "INTERNETHISTORY"; break; case SpecialFolder.ApplicationData: envVar = "APPDATA"; break; case SpecialFolder.LocalApplicationData: envVar = "LOCALAPPDATA"; break; case SpecialFolder.UserProfile: envVar = "USERPROFILE"; break; case SpecialFolder.Cookies: envVar = "INETCOOKIES"; break; } if (envVar != null && s_envVars.TryGetValue(envVar, out var path)) { return(path); } } // there is either no profile redirect or we could not find the corresponding path in the provided dictionary return(Environment.GetFolderPath(folder, option)); }
/// <summary> /// ディレクトリ選択ダイアログから選択したパスを取得 /// </summary> /// <param name="titleMsg">ダイアログのタイトル</param> /// <param name="rootFolder">ルートフォルダ</param> /// <param name="selectedPath">初期選択フォルダ</param> /// <param name="showNewFolderButton">ユーザーが新しいフォルダを作成できる</param> /// <returns>選択したディレクトリパス</returns> public static string GetSelectedDirectory(string titleMsg, System.Environment.SpecialFolder rootFolder, string selectedPath, bool showNewFolderButton) { string retSelectedDirectory = ""; //FolderBrowserDialogクラスのインスタンスを作成 FolderBrowserDialog fbd = new FolderBrowserDialog(); try { //上部に表示する説明テキスト fbd.Description = titleMsg; //ルートフォルダ fbd.RootFolder = rootFolder; //最初に選択するフォルダを指定する //RootFolder以下にあるフォルダである必要がある //fbd.SelectedPath = @"C:\Windows"; if (!String.IsNullOrEmpty(selectedPath)) { fbd.SelectedPath = selectedPath; } //ユーザーが新しいフォルダを作成できるようにする fbd.ShowNewFolderButton = showNewFolderButton; //ダイアログを表示する if (fbd.ShowDialog() == DialogResult.OK) { //選択されたフォルダを設定する retSelectedDirectory = fbd.SelectedPath; } } catch (Exception) { throw; } finally { fbd.Dispose(); } return(retSelectedDirectory); }
/// <summary> /// Determine whether a special folder has physical information on current computer or not. /// </summary> /// <param name="specialFolder"></param> /// <returns>Path to special folder (if any) or null</returns> public static string SpecialFolderHasPath(System.Environment.SpecialFolder specialFolder) { string path = null; try { path = Environment.GetFolderPath(specialFolder); if (string.IsNullOrEmpty(path) == true) { return(null); } else { return(path); } } catch { return(null); } }
/// <summary> /// Resets all properties to their default values. /// </summary> public override void Reset() { _description = string.Empty; _useDescriptionForTitle = false; _selectedPath = string.Empty; _rootFolder = Environment.SpecialFolder.Desktop; _showNewFolderButton = true; }
public ComboItem(ES value, string title) { this.Title = title; this.Value = value; }