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


C# SpecialFolder类代码示例

本文整理汇总了C#中SpecialFolder的典型用法代码示例。如果您正苦于以下问题:C# SpecialFolder类的具体用法?C# SpecialFolder怎么用?C# SpecialFolder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: UnixGetFolderPath

		// needed by our BCL, e.g. IsolatedStorageFile.cs
		internal static string UnixGetFolderPath (SpecialFolder folder, SpecialFolderOption option)
		{
			var dir = iOSGetFolderPath (folder);
			if ((option == SpecialFolderOption.Create) && !Directory.Exists (dir))
				Directory.CreateDirectory (dir);
			return dir;
		}
开发者ID:ItsVeryWindy,项目名称:mono,代码行数:8,代码来源:Environment.iOS.cs

示例2: GetSpecialFolderAttribute

		static FolderAttributes GetSpecialFolderAttribute (SpecialFolder special)
		{
			switch (special) {
			case SpecialFolder.All:     return FolderAttributes.All;
			case SpecialFolder.Archive: return FolderAttributes.Archive;
			case SpecialFolder.Drafts:  return FolderAttributes.Drafts;
			case SpecialFolder.Flagged: return FolderAttributes.Flagged;
			case SpecialFolder.Junk:    return FolderAttributes.Junk;
			case SpecialFolder.Sent:    return FolderAttributes.Sent;
			case SpecialFolder.Trash:   return FolderAttributes.Trash;
			default: throw new ArgumentOutOfRangeException ();
			}
		}
开发者ID:jstedfast,项目名称:MailKit,代码行数:13,代码来源:ImapClientTests.cs

示例3: GetFolderPathCore

        private static string GetFolderPathCore(SpecialFolder folder, SpecialFolderOption option)
        {
            // Get the path for the SpecialFolder
            string path = GetFolderPathCoreWithoutValidation(folder);
            Debug.Assert(path != null);

            // If we didn't get one, or if we got one but we're not supposed to verify it,
            // or if we're supposed to verify it and it passes verification, return the path.
            if (path.Length == 0 ||
                option == SpecialFolderOption.DoNotVerify ||
                Interop.Sys.Access(path, Interop.Sys.AccessMode.R_OK) == 0)
            {
                return path;
            }

            // Failed verification.  If None, then we're supposed to return an empty string.
            // If Create, we're supposed to create it and then return the path.
            if (option == SpecialFolderOption.None)
            {
                return string.Empty;
            }
            else
            {
                Debug.Assert(option == SpecialFolderOption.Create);

                // TODO #11151: Replace with Directory.CreateDirectory once we have access to System.IO.FileSystem here.
                Action<string> createDirectory = LazyInitializer.EnsureInitialized(ref s_directoryCreateDirectory, () =>
                {
                    Type dirType = Type.GetType("System.IO.Directory, System.IO.FileSystem, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", throwOnError: true);
                    MethodInfo mi = dirType.GetTypeInfo().GetDeclaredMethod("CreateDirectory");
                    return (Action<string>)mi.CreateDelegate(typeof(Action<string>));
                });
                createDirectory(path);

                return path;
            }
        }
开发者ID:chcosta,项目名称:corefx,代码行数:37,代码来源:Environment.Unix.cs

示例4: InternalGetFolderPath

		// the security runtime (and maybe other parts of corlib) needs the
		// information to initialize themselves before permissions can be checked
		internal static string InternalGetFolderPath (SpecialFolder folder)
		{
			string home = internalGetHome ();

			// http://freedesktop.org/Standards/basedir-spec/basedir-spec-0.6.html

			// note: skip security check for environment variables
			string data = internalGetEnvironmentVariable ("XDG_DATA_HOME");
			if ((data == null) || (data == String.Empty)) {
				data = Path.Combine (home, ".local");
				data = Path.Combine (data, "share");
			}

			// note: skip security check for environment variables
			string config = internalGetEnvironmentVariable ("XDG_CONFIG_HOME");
			if ((config == null) || (config == String.Empty)) {
				config = Path.Combine (home, ".config");
			}

			switch (folder) {
			// MyComputer is a virtual directory
			case SpecialFolder.MyComputer:
				return String.Empty;

			// personal == ~
			case SpecialFolder.Personal:
#if MONOTOUCH
				return Path.Combine (home, "Documents");
#else
				return home;
#endif
			// use FDO's CONFIG_HOME. This data will be synced across a network like the windows counterpart.
			case SpecialFolder.ApplicationData:
				return config;
			//use FDO's DATA_HOME. This is *NOT* synced
			case SpecialFolder.LocalApplicationData:
				return data;
			case SpecialFolder.Desktop:
			case SpecialFolder.DesktopDirectory:
				return ReadXdgUserDir (config, home, "XDG_DESKTOP_DIR", "Desktop");

			case SpecialFolder.MyMusic:
				return ReadXdgUserDir (config, home, "XDG_MUSIC_DIR", "Music");

			case SpecialFolder.MyPictures:
				return ReadXdgUserDir (config, home, "XDG_PICTURES_DIR", "Pictures");
				
			// these simply dont exist on Linux
			// The spec says if a folder doesnt exist, we
			// should return ""
			case SpecialFolder.Favorites:
			case SpecialFolder.Programs:
			case SpecialFolder.SendTo:
			case SpecialFolder.StartMenu:
			case SpecialFolder.Startup:
			case SpecialFolder.Templates:
			case SpecialFolder.Cookies:
			case SpecialFolder.History:
			case SpecialFolder.InternetCache:
			case SpecialFolder.Recent:
			case SpecialFolder.CommonProgramFiles:
			case SpecialFolder.ProgramFiles:
			case SpecialFolder.System:
				return String.Empty;
			// This is where data common to all users goes
			case SpecialFolder.CommonApplicationData:
				return "/usr/share";
			default:
				throw new ArgumentException ("Invalid SpecialFolder");
                        }
                }
开发者ID:tgiphil,项目名称:Mono-Class-Libraries,代码行数:73,代码来源:Environment.Original.cs

示例5: GetFolder

        /// <summary>
        /// Gets the specified special folder.
        /// </summary>
        /// <remarks>
        /// Not all IMAP servers support special folders. Only IMAP servers
        /// supporting the <see cref="ImapCapabilities.SpecialUse"/> or
        /// <see cref="ImapCapabilities.XList"/> extensions may have
        /// special folders.
        /// </remarks>
        /// <returns>The folder if available; otherwise <c>null</c>.</returns>
        /// <param name="folder">The type of special folder.</param>
        /// <exception cref="System.ArgumentOutOfRangeException">
        /// <paramref name="folder"/> is out of range.
        /// </exception>
        /// <exception cref="System.ObjectDisposedException">
        /// The <see cref="ImapClient"/> has been disposed.
        /// </exception>
        /// <exception cref="System.InvalidOperationException">
        /// <para>The <see cref="ImapClient"/> is not connected.</para>
        /// <para>-or-</para>
        /// <para>The <see cref="ImapClient"/> is not authenticated.</para>
        /// </exception>
        public IFolder GetFolder(SpecialFolder folder)
        {
            CheckDisposed ();

            if (!IsConnected)
                throw new InvalidOperationException ("The ImapClient is not connected.");

            if (engine.State != ImapEngineState.Authenticated && engine.State != ImapEngineState.Selected)
                throw new InvalidOperationException ("The ImapClient is not authenticated.");

            switch (folder) {
            case SpecialFolder.All:     return engine.All;
            case SpecialFolder.Archive: return engine.Archive;
            case SpecialFolder.Drafts:  return engine.Drafts;
            case SpecialFolder.Flagged: return engine.Flagged;
            case SpecialFolder.Junk:    return engine.Junk;
            case SpecialFolder.Sent:    return engine.Sent;
            case SpecialFolder.Trash:   return engine.Trash;
            default: throw new ArgumentOutOfRangeException ("folder");
            }
        }
开发者ID:judicapo,项目名称:MailKit,代码行数:43,代码来源:ImapClient.cs

示例6: GetFolderPath

		static string GetFolderPath(SpecialFolder folder, SpecialFolderOption option)
		{
			SecurityManager.EnsureElevatedPermissions (); // this is a no-op outside moonlight

			string dir = null;

			if (Environment.IsRunningOnWindows)
				dir = GetWindowsFolderPath ((int) folder);
			else
				dir = UnixGetFolderPath (folder, option);

#if !NET_2_1
			if ((dir != null) && (dir.Length > 0) && SecurityManager.SecurityEnabled) {
				new FileIOPermission (FileIOPermissionAccess.PathDiscovery, dir).Demand ();
			}
#endif
			return dir;
		}
开发者ID:singmelody,项目名称:mono,代码行数:18,代码来源:Environment.cs

示例7: GetFolder

 public IMailFolder GetFolder(SpecialFolder folder)
 {
     return _imapClient.GetFolder(folder);
 }
开发者ID:ptfuller,项目名称:InboxWatcher,代码行数:4,代码来源:ImapClientWrapper.cs

示例8: UnsafeGetFolderPath

 internal static string UnsafeGetFolderPath(SpecialFolder folder)
 {
     return InternalGetFolderPath(folder, SpecialFolderOption.None, suppressSecurityChecks: true);
 }
开发者ID:JokerMisfits,项目名称:linux-packaging-mono,代码行数:4,代码来源:environment.cs

示例9: GetFolderPath

	// Get a path to a specific system folder.
	public static String GetFolderPath(SpecialFolder folder)
			{
				// We can use the operating system under Win32.
				if(InfoMethods.GetPlatformID() != PlatformID.Unix)
				{
					// Allocate a buffer to hold the result path.
					IntPtr buffer = Marshal.AllocHGlobal(260 /*MAX_PATH*/ + 1);

					// Call "SHGetFolderPath" to retrieve the path.
					try
					{
						SHGetFolderPathA(IntPtr.Zero, (int)folder,
									     IntPtr.Zero, 0, buffer);
						String value = Marshal.PtrToStringAnsi(buffer);
						if(value != null && value.Length != 0)
						{
							Marshal.FreeHGlobal(buffer);
							return value;
						}
					}
					catch(Exception)
					{
						// We weren't able to find the function in the DLL.
					}
					Marshal.FreeHGlobal(buffer);
				}

				// Special handling for some of the cases.
				String dir = null;
				switch(folder)
				{
					case SpecialFolder.System:
					{
						dir = DirMethods.GetSystemDirectory();
					}
					break;

					case SpecialFolder.ApplicationData:
					{
						dir = InfoMethods.GetUserStorageDir() +
							  Path.DirectorySeparatorChar +
							  "ApplicationData";
					}
					break;

					case SpecialFolder.LocalApplicationData:
					{
						dir = InfoMethods.GetUserStorageDir() +
							  Path.DirectorySeparatorChar +
							  "LocalApplicationData";
					}
					break;

					case SpecialFolder.CommonApplicationData:
					{
						dir = InfoMethods.GetUserStorageDir() +
							  Path.DirectorySeparatorChar +
							  "CommonApplicationData";
					}
					break;
				}
				if(dir != null && dir.Length > 0)
				{
					return dir;
				}

				// The empty string indicates that the value is not present.
				return String.Empty;
			}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:70,代码来源:Environment.cs

示例10: Create

		/// <summary>
		/// Create a new subfolder with the given name.
		/// </summary>
		/// <remarks>
		/// Creates a new subfolder with the given name.
		/// </remarks>
		/// <returns>The created folder.</returns>
		/// <param name="name">The name of the folder to create.</param>
		/// <param name="specialUse">The special use for the folder being created.</param>
		/// <param name="cancellationToken">The cancellation token.</param>
		/// <exception cref="System.ArgumentNullException">
		/// <paramref name="name"/> is <c>null</c>.
		/// </exception>
		/// <exception cref="System.ArgumentException">
		/// <paramref name="name"/> is empty.
		/// </exception>
		/// <exception cref="System.ObjectDisposedException">
		/// The <see cref="IMailStore"/> has been disposed.
		/// </exception>
		/// <exception cref="ServiceNotConnectedException">
		/// The <see cref="IMailStore"/> is not connected.
		/// </exception>
		/// <exception cref="ServiceNotAuthenticatedException">
		/// The <see cref="IMailStore"/> is not authenticated.
		/// </exception>
		/// <exception cref="System.InvalidOperationException">
		/// The <see cref="DirectorySeparator"/> is nil, and thus child folders cannot be created.
		/// </exception>
		/// <exception cref="System.NotSupportedException">
		/// The <see cref="MailService"/> does not support the creation of special folders.
		/// </exception>
		/// <exception cref="System.OperationCanceledException">
		/// The operation was canceled via the cancellation token.
		/// </exception>
		/// <exception cref="System.IO.IOException">
		/// An I/O error occurred.
		/// </exception>
		/// <exception cref="ProtocolException">
		/// The server's response contained unexpected tokens.
		/// </exception>
		/// <exception cref="CommandException">
		/// The command failed.
		/// </exception>
		public virtual IMailFolder Create (string name, SpecialFolder specialUse, CancellationToken cancellationToken = default (CancellationToken))
		{
			return Create (name, new [] { specialUse }, cancellationToken);
		}
开发者ID:jstedfast,项目名称:MailKit,代码行数:47,代码来源:MailFolder.cs

示例11: GetFolderPath

 public override string GetFolderPath(SpecialFolder folder, bool create)
 {
     var dir = Far.Api.GetFolderPath(folder) + @"\FarNet\" + ModuleName;
     if (create && !Directory.Exists(dir))
         Directory.CreateDirectory(dir);
     return dir;
 }
开发者ID:pezipink,项目名称:FarNet,代码行数:7,代码来源:ModuleManager.cs

示例12: AddAndCreateSpecialFolder

        private void AddAndCreateSpecialFolder(SpecialFolder folder, string path)
        {
            var combinedPath = Path.Combine(path, folder == SpecialFolder.Root ? string.Empty : folder.ToString());

            Directory.CreateDirectory(combinedPath);

            AddSpecialFolder(folder, combinedPath);
        }
开发者ID:DaniilMonin,项目名称:Expanse.js,代码行数:8,代码来源:BaseProjectExportTemplate.cs

示例13: AddSpecialFolder

 private void AddSpecialFolder(SpecialFolder folder, string path) => _folders.Add(folder, path);
开发者ID:DaniilMonin,项目名称:Expanse.js,代码行数:1,代码来源:BaseProjectExportTemplate.cs

示例14: GetSpecialFolder

 protected string GetSpecialFolder(SpecialFolder folder) => _folders[folder];
开发者ID:DaniilMonin,项目名称:Expanse.js,代码行数:1,代码来源:BaseProjectExportTemplate.cs

示例15: GetEnsuredPath

 public string GetEnsuredPath(string path, SpecialFolder folder)
 {
     return GetEnsuredPath(folder + "\\" + path, false);
 }
开发者ID:NatashaSchutte,项目名称:Warewolf-ESB,代码行数:4,代码来源:StudioFileSystem.cs


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