当前位置: 首页>>代码示例>>C#>>正文


C# Environment.ToString方法代码示例

本文整理汇总了C#中System.Environment.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# Environment.ToString方法的具体用法?C# Environment.ToString怎么用?C# Environment.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Environment的用法示例。


在下文中一共展示了Environment.ToString方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AddSpecialFolder

 private static void AddSpecialFolder(Environment.SpecialFolder sf)
 {
     try
     {
         AddSpecialFolder(sf.ToString(), Environment.GetFolderPath(sf));
     }
     catch
     {
     }
 }
开发者ID:CuneytKukrer,项目名称:TestProject,代码行数:10,代码来源:PathHelper.cs

示例2: IsEnvironment

 public static bool IsEnvironment(Environment env)
 {
     return ConfigurationManager.AppSettings["Environment"] == env.ToString();
 }
开发者ID:maxcnunes,项目名称:Perfin,代码行数:4,代码来源:ConfigurationManagerHelper.cs

示例3: RemoveShortcut

        public static void RemoveShortcut(Environment.SpecialFolder directory, String subdir = "")
        {
            try {
                log.Debug("RemoveShortcut: directory=" + directory.ToString() + "; subdir=" + subdir);
                if (subdir != "") subdir = "\\" + subdir;
                String shortcutDir = Environment.GetFolderPath(directory) + subdir;

                if (!System.IO.Directory.Exists(shortcutDir)) {
                    log.Info("Failed to delete shortcut in \"" + shortcutDir + "\" - directory does not exist.");
                    return;
                }
                foreach (String file in System.IO.Directory.GetFiles(shortcutDir)) {
                    if (file.EndsWith("\\OutlookGoogleCalendarSync.lnk") || //legacy name <=v2.1.0.0
                        file.EndsWith("\\" + Application.ProductName + ".lnk")) {
                        System.IO.File.Delete(file);
                        log.Info("Deleted shortcut in \"" + shortcutDir + "\"");
                        break;
                    }
                }
            } catch (System.Exception ex) {
                log.Warn("Problem trying to remove legacy Start Menu shortcut.");
                log.Error(ex.Message);
            }
        }
开发者ID:dsuess,项目名称:OutlookGoogleSync,代码行数:24,代码来源:Program.cs

示例4: CheckShortcut

        //public static void AddShortcut(Environment.SpecialFolder directory, String subdir = "") {
        //    log.Debug("AddShortcut: directory=" + directory.ToString() + "; subdir=" + subdir);
        //    String appPath = Application.ExecutablePath;
        //    if (subdir != "") subdir = "\\" + subdir;
        //    String shortcutDir = Environment.GetFolderPath(directory) + subdir;
        //    if (!System.IO.Directory.Exists(shortcutDir)) {
        //        log.Debug("Creating directory " + shortcutDir);
        //        System.IO.Directory.CreateDirectory(shortcutDir);
        //    }
        //    string shortcutLocation = System.IO.Path.Combine(shortcutDir, Application.ProductName + ".lnk");
        //    #region "Windows Script Host Object Model - 32bit only"
        //    /*
        //    IWshRuntimeLibrary.WshShell shell = new IWshRuntimeLibrary.WshShell();
        //    IWshRuntimeLibrary.IWshShortcut shortcut = shell.CreateShortcut(shortcutLocation) as IWshRuntimeLibrary.WshShortcut;
        //    shortcut.Description = "Synchronise Outlook and Google calendars";
        //    shortcut.IconLocation = appPath.ToLower().Replace("OutlookGoogleCalendarSync.exe", "icon.ico");
        //    shortcut.TargetPath = appPath;
        //    shortcut.WorkingDirectory = Application.StartupPath;
        //    shortcut.Save();
        //    */
        //    #endregion
        //    #region "C:\Windows\System32\shell32.dll - works but only compiles in VSE 2010?!"
        //    /*
        //    System.IO.File.WriteAllBytes(shortcutLocation, new byte[] { });
        //    //Initialize a ShellLinkObject for that .lnk file
        //    Shell32.Shell shl = new Shell32.ShellClass();
        //    Shell32.Folder dir = shl.NameSpace(shortcutDir);
        //    Shell32.FolderItem itm = dir.Items().Item(Application.ProductName + ".lnk");
        //    Shell32.ShellLinkObject lnk = (Shell32.ShellLinkObject)itm.GetLink;
        //    lnk.Path = appPath;
        //    lnk.Description = "Synchronise Outlook and Google calendars";
        //    lnk.WorkingDirectory = Application.StartupPath;
        //    lnk.SetIconLocation(appPath.ToLower().Replace("OutlookGoogleCalendarSync.exe", "icon.ico"), 0);
        //    lnk.Save(shortcutLocation);
        //    */
        //    #endregion
        //    log.Info("Created shortcut in \"" + shortcutDir + "\"");
        //}
        public static Boolean CheckShortcut(Environment.SpecialFolder directory, String subdir = "")
        {
            log.Debug("CheckShortcut: directory=" + directory.ToString() + "; subdir=" + subdir);
            Boolean foundShortcut = false;
            if (subdir != "") subdir = "\\" + subdir;
            String shortcutDir = Environment.GetFolderPath(directory) + subdir;

            if (!System.IO.Directory.Exists(shortcutDir)) return false;

            foreach (String file in System.IO.Directory.GetFiles(shortcutDir)) {
                if (file.EndsWith("\\OutlookGoogleCalendarSync.lnk") || //legacy name <=v2.1.0.0
                    file.EndsWith("\\" + Application.ProductName + ".lnk")) {
                    foundShortcut = true;
                    break;
                }
            }
            return foundShortcut;
        }
开发者ID:dsuess,项目名称:OutlookGoogleSync,代码行数:56,代码来源:Program.cs

示例5: RemoveShortcut

        public static void RemoveShortcut(Environment.SpecialFolder directory, String subdir = "") {
            log.Debug("RemoveShortcut: directory=" + directory.ToString() + "; subdir=" + subdir);
            if (subdir != "") subdir = "\\" + subdir;
            String shortcutDir = Environment.GetFolderPath(directory) + subdir;

            if (!System.IO.Directory.Exists(shortcutDir)) {
                log.Info("Failed to delete shortcut in \"" + shortcutDir + "\" - directory does not exist.");
                return;
            }
            foreach (String file in System.IO.Directory.GetFiles(shortcutDir)) {
                if (file.EndsWith("\\OutlookGoogleCalendarSync.lnk")) {
                    System.IO.File.Delete(file);
                    log.Info("Deleted shortcut in \"" + shortcutDir + "\"");
                    break;
                }
            }
        }
开发者ID:EduShareGeorgian,项目名称:OutlookGoogleSync,代码行数:17,代码来源:Program.cs

示例6: AddShortcut

        public static void AddShortcut(Environment.SpecialFolder directory, String subdir = "") {
            log.Debug("AddShortcut: directory=" + directory.ToString() + "; subdir=" + subdir);
            String appPath = Application.ExecutablePath;
            if (subdir != "") subdir = "\\" + subdir;
            String shortcutDir = Environment.GetFolderPath(directory) + subdir;

            if (!System.IO.Directory.Exists(shortcutDir)) {
                log.Debug("Creating directory " + shortcutDir);
                System.IO.Directory.CreateDirectory(shortcutDir);
            }

            string shortcutLocation = System.IO.Path.Combine(shortcutDir, "OutlookGoogleCalendarSync.lnk");
            IWshRuntimeLibrary.WshShell shell = new IWshRuntimeLibrary.WshShell();
            IWshRuntimeLibrary.IWshShortcut shortcut = shell.CreateShortcut(shortcutLocation) as IWshRuntimeLibrary.WshShortcut;

            shortcut.Description = "Synchronise Outlook and Google calendars";
            shortcut.IconLocation = appPath.ToLower().Replace("OutlookGoogleCalendarSync.exe", "icon.ico");
            shortcut.TargetPath = appPath;
            shortcut.WorkingDirectory = Application.StartupPath;
            shortcut.Save();
            log.Info("Created shortcut in \"" + shortcutDir + "\"");
        }
开发者ID:EduShareGeorgian,项目名称:OutlookGoogleSync,代码行数:22,代码来源:Program.cs

示例7: GetDisplayName

        private static string GetDisplayName(Environment.SpecialFolder sf)
        {
            string path = Environment.GetFolderPath(sf, Environment.SpecialFolderOption.Create);
            if (Directory.Exists(path))
            {
                return System.IO.Path.GetFileName(path);
            }

            return sf.ToString();
        }
开发者ID:rraguso,项目名称:protone-suite,代码行数:10,代码来源:OPMFileDialog.cs

示例8: Shortcut

 public Shortcut(Environment.SpecialFolder specialFolder) {
     var folder = new Folder(Environment.GetFolderPath(specialFolder));
     name = folder.Name;
     command = folder.FullName;
     icon = new PluginIconLoader().Png(specialFolder.ToString());
 }
开发者ID:srushti,项目名称:azazel,代码行数:6,代码来源:ShortcutsPlugin.cs


注:本文中的System.Environment.ToString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。