コード例 #1
0
ファイル: EtoEnvironmentHandler.cs プロジェクト: M1C/Eto
 public string GetFolderPath(EtoSpecialFolder folder)
 {
     NSSearchPathDirectory dir;
     NSSearchPathDomain domain;
     Convert (folder, out dir, out domain);
     return NSSearchPath.GetDirectories (dir, domain, true).FirstOrDefault ();
 }
コード例 #2
0
ファイル: EtoEnvironmentHandler.cs プロジェクト: sami1971/Eto
        public string GetFolderPath(EtoSpecialFolder folder)
        {
            NSSearchPathDirectory dir;
            NSSearchPathDomain    domain;

            switch (folder)
            {
            case EtoSpecialFolder.ApplicationResources:
                return(NSBundle.MainBundle.ResourcePath);

            case EtoSpecialFolder.ApplicationSettings:
                Convert(folder, out dir, out domain);
                var path = NSSearchPath.GetDirectories(dir, domain).FirstOrDefault();
                path = System.IO.Path.Combine(path, NSBundle.MainBundle.BundleIdentifier);
                if (!System.IO.Directory.Exists(path))
                {
                    System.IO.Directory.CreateDirectory(path);
                }
                return(path);

            default:
                Convert(folder, out dir, out domain);
                return(NSSearchPath.GetDirectories(dir, domain).FirstOrDefault());
            }
        }
コード例 #3
0
ファイル: EtoEnvironmentHandler.cs プロジェクト: M1C/Eto
 Environment.SpecialFolder Convert(EtoSpecialFolder folder)
 {
     switch (folder)
     {
     case EtoSpecialFolder.ApplicationSettings: return Environment.SpecialFolder.ApplicationData;
     case EtoSpecialFolder.Documents: return Environment.SpecialFolder.MyDocuments;
     default: throw new NotSupportedException();
     }
 }
コード例 #4
0
		public string GetFolderPath (EtoSpecialFolder folder)
		{
			switch (folder) {
			case EtoSpecialFolder.ApplicationResources:
				return Path.GetDirectoryName (Assembly.GetEntryAssembly ().Location);
			default:
				return Environment.GetFolderPath (Convert (folder));
			}
		}
コード例 #5
0
		public string GetFolderPath (EtoSpecialFolder folder)
		{
			NSSearchPathDirectory dir;
			NSSearchPathDomain domain;
			Convert (folder, out dir, out domain);
			
			var manager = new NSFileManager();
			NSError error;
			var path = manager.GetUrl(dir, domain, null, false, out error);
			return path.Path;
		}
コード例 #6
0
        public string GetFolderPath(EtoSpecialFolder folder)
        {
            switch (folder)
            {
            case EtoSpecialFolder.ApplicationResources:
                return(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location));

            default:
                return(Environment.GetFolderPath(Convert(folder)));
            }
        }
コード例 #7
0
		public string GetFolderPath (EtoSpecialFolder folder)
		{
			switch (folder) {
			case EtoSpecialFolder.ApplicationResources:
				return NSBundle.MainBundle.ResourcePath;
			default:
				NSSearchPathDirectory dir;
				NSSearchPathDomain domain;
				Convert (folder, out dir, out domain);
				return NSSearchPath.GetDirectories (dir, domain, true).FirstOrDefault ();
			}
		}
コード例 #8
0
        public string GetFolderPath(EtoSpecialFolder folder)
        {
            string homeDir = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);

            switch (folder)
            {
            // Currently has a bug on dotnet where it returns the wrong path for Mac
            // https://github.com/dotnet/runtime/issues/63214#issuecomment-1003414322
            case EtoSpecialFolder.ApplicationSettings:
                if (UseXDG && EtoEnvironment.Platform.IsMac)
                {
                    return(Path.Combine(homeDir, "Library", "Application Support"));
                }
                return(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData));

            case EtoSpecialFolder.ApplicationResources:
                return(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location));

            case EtoSpecialFolder.EntryExecutable:
                var path = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
                if (String.IsNullOrEmpty(path))
                {
                    path = Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName);
                }
                return(path);

            // Currently has a bug on dotnet, where it returns the wrong path for Linux+Mac
            // See link above
            case EtoSpecialFolder.Documents:
                if (UseXDG && EtoEnvironment.Platform.IsMac)
                {
                    return(Path.Combine(homeDir, "Documents"));
                }
                if (UseXDG && EtoEnvironment.Platform.IsLinux)
                {
                    return(GetXdgUserDirectory(homeDir, "XDG_DOCUMENTS_DIR", "Documents"));
                }
                return(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments));

            case EtoSpecialFolder.Downloads:
                if (UseXDG && EtoEnvironment.Platform.IsLinux)
                {
                    return(GetXdgUserDirectory(homeDir, "XDG_DOWNLOAD_DIR", "Downloads"));
                }

                // This technically doesn't return the proper download path for Windows on UseXDG, but it's not really a priority to implement.
                // If someone wants to implement this to call SHGetFolderPath on Windows, feel free to PR.
                return(Path.Combine(homeDir, "Downloads"));

            default:
                throw new NotSupportedException();
            }
        }
コード例 #9
0
        public string GetFolderPath(EtoSpecialFolder folder)
        {
            NSSearchPathDirectory dir;
            NSSearchPathDomain    domain;

            Convert(folder, out dir, out domain);

            var     manager = new NSFileManager();
            NSError error;
            var     path = manager.GetUrl(dir, domain, null, false, out error);

            return(path.Path);
        }
コード例 #10
0
ファイル: EtoEnvironmentHandler.cs プロジェクト: nzysoft/Eto
        static Environment.SpecialFolder Convert(EtoSpecialFolder folder)
        {
            switch (folder)
            {
            case EtoSpecialFolder.ApplicationSettings:
                return(Environment.SpecialFolder.ApplicationData);

            case EtoSpecialFolder.Documents:
                return(Environment.SpecialFolder.MyDocuments);

            default:
                throw new NotSupportedException();
            }
        }
コード例 #11
0
        public string GetFolderPath(EtoSpecialFolder folder)
        {
            switch (folder)
            {
            case EtoSpecialFolder.ApplicationResources:
            case EtoSpecialFolder.EntryExecutable:
                return(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location));

            case EtoSpecialFolder.Downloads:
                return(Microsoft.WindowsAPICodePack.Shell.KnownFolders.Downloads.Path);

            default:
                return(Environment.GetFolderPath(Convert(folder)));
            }
        }
コード例 #12
0
ファイル: EtoEnvironmentHandler.cs プロジェクト: nzysoft/Eto
        public string GetFolderPath(EtoSpecialFolder folder)
        {
#if TODO_XAML
            switch (folder)
            {
            case EtoSpecialFolder.ApplicationResources:
                return(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location));

            default:
                return(Environment.GetFolderPath(Convert(folder)));
            }
#else
            throw new NotImplementedException();
#endif
        }
コード例 #13
0
		void Convert (EtoSpecialFolder folder, out NSSearchPathDirectory dir, out NSSearchPathDomain domain)
		{
			switch (folder) {
			case EtoSpecialFolder.ApplicationSettings:
				dir = NSSearchPathDirectory.ApplicationSupportDirectory;
				domain = NSSearchPathDomain.User;
				break;
			case EtoSpecialFolder.Documents:
				dir = NSSearchPathDirectory.DocumentDirectory;
				domain = NSSearchPathDomain.User;
				break;
			default:
				throw new NotSupportedException ();
			}
		}
コード例 #14
0
        void Convert(EtoSpecialFolder folder, out NSSearchPathDirectory dir, out NSSearchPathDomain domain)
        {
            switch (folder)
            {
            case EtoSpecialFolder.ApplicationSettings:
                dir    = NSSearchPathDirectory.ApplicationSupportDirectory;
                domain = NSSearchPathDomain.User;
                break;

            case EtoSpecialFolder.Documents:
                dir    = NSSearchPathDirectory.DocumentDirectory;
                domain = NSSearchPathDomain.User;
                break;

            default:
                throw new NotSupportedException();
            }
        }
コード例 #15
0
		public string GetFolderPath (EtoSpecialFolder folder)
		{
			NSSearchPathDirectory dir;
			NSSearchPathDomain domain;
			switch (folder) {
			case EtoSpecialFolder.ApplicationResources:
				return NSBundle.MainBundle.ResourcePath;
			case EtoSpecialFolder.ApplicationSettings:
				Convert (folder, out dir, out domain);
				var path = NSSearchPath.GetDirectories (dir, domain, true).FirstOrDefault ();
				path = System.IO.Path.Combine (path, NSBundle.MainBundle.BundleIdentifier);
				if (!System.IO.Directory.Exists (path))
					System.IO.Directory.CreateDirectory (path);
				return path;
			default:
				Convert (folder, out dir, out domain);
				return NSSearchPath.GetDirectories (dir, domain, true).FirstOrDefault ();
			}
		}
コード例 #16
0
ファイル: EtoEnvironmentHandler.cs プロジェクト: nzysoft/Eto
        public string GetFolderPath(EtoSpecialFolder folder)
        {
            switch (folder)
            {
            case EtoSpecialFolder.ApplicationResources:
                return(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location));

            case EtoSpecialFolder.EntryExecutable:
            {
                var path = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
                if (string.IsNullOrEmpty(path))
                {
                    path = Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName);
                }
                return(path);
            }

            default:
                return(Environment.GetFolderPath(Convert(folder)));
            }
        }
コード例 #17
0
ファイル: EtoEnvironmentHandler.cs プロジェクト: nzysoft/Eto
        public string GetFolderPath(EtoSpecialFolder folder)
        {
            NSSearchPathDirectory dir;
            NSSearchPathDomain    domain;

            switch (folder)
            {
            case EtoSpecialFolder.ApplicationResources:
                return(NSBundle.MainBundle.ResourcePath);

            case EtoSpecialFolder.EntryExecutable:
            {
                var path = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
                if (string.IsNullOrEmpty(path))
                {
                    path = Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName);
                }
                return(path);
            }

            case EtoSpecialFolder.ApplicationSettings:
            {
                Convert(folder, out dir, out domain);
                var path = NSSearchPath.GetDirectories(dir, domain).FirstOrDefault();
                path = Path.Combine(path, NSBundle.MainBundle.BundleIdentifier);
                if (!Directory.Exists(path))
                {
                    Directory.CreateDirectory(path);
                }
                return(path);
            }

            default:
                Convert(folder, out dir, out domain);
                return(NSSearchPath.GetDirectories(dir, domain).FirstOrDefault());
            }
        }
コード例 #18
0
ファイル: EtoEnvironment.cs プロジェクト: majorsilence/Eto
		/// <summary>
		/// Gets the folder path for the specified special folder
		/// </summary>
		/// <param name="g">Generator to use</param>
		/// <param name="folder">Special folder to retrieve the path for</param>
		/// <returns>Path of the specified folder</returns>
		public static string GetFolderPath (Generator g, EtoSpecialFolder folder)
		{
			var handler = g.CreateHandler<IEtoEnvironment>();
			return handler.GetFolderPath(folder);
		}
コード例 #19
0
ファイル: EtoEnvironment.cs プロジェクト: modulexcite/Eto-1
        /// <summary>
        /// Gets the folder path for the specified special folder
        /// </summary>
        /// <param name="g">Generator to use</param>
        /// <param name="folder">Special folder to retrieve the path for</param>
        /// <returns>Path of the specified folder</returns>
        public static string GetFolderPath(Generator g, EtoSpecialFolder folder)
        {
            var handler = g.CreateHandler <IEtoEnvironment>();

            return(handler.GetFolderPath(folder));
        }
コード例 #20
0
ファイル: EtoEnvironment.cs プロジェクト: modulexcite/Eto-1
 /// <summary>
 /// Gets the folder path for the specified special folder
 /// </summary>
 /// <param name="folder">Special folder to retrieve the path for</param>
 /// <returns>Path of the specified folder</returns>
 public static string GetFolderPath(EtoSpecialFolder folder)
 {
     return(GetFolderPath(Generator.Current, folder));
 }
コード例 #21
0
ファイル: EtoEnvironment.cs プロジェクト: sami1971/Eto
        /// <summary>
        /// Gets the folder path for the specified special folder
        /// </summary>
        /// <param name="folder">Special folder to retrieve the path for</param>
        /// <param name="generator">Generator to get the folder path with</param>
        /// <returns>Path of the specified folder</returns>
        public static string GetFolderPath(EtoSpecialFolder folder, Generator generator = null)
        {
            var handler = generator.CreateShared <IEtoEnvironment> ();

            return(handler.GetFolderPath(folder));
        }
コード例 #22
0
ファイル: EtoEnvironment.cs プロジェクト: sami1971/Eto
 public static string GetFolderPath(Generator g, EtoSpecialFolder folder)
 {
     return(GetFolderPath(folder, g));
 }
コード例 #23
0
ファイル: EtoEnvironment.cs プロジェクト: mhusen/Eto
		/// <summary>
		/// Gets the folder path for the specified special folder
		/// </summary>
		/// <param name="folder">Special folder to retrieve the path for</param>
		/// <returns>Path of the specified folder</returns>
		public static string GetFolderPath(EtoSpecialFolder folder)
		{
			var handler = Eto.Platform.Instance.CreateShared<IHandler>();
			return handler.GetFolderPath(folder);
		}
コード例 #24
0
ファイル: EtoEnvironmentHandler.cs プロジェクト: M1C/Eto
 public string GetFolderPath(EtoSpecialFolder folder)
 {
     return Environment.GetFolderPath(Convert(folder));
 }
コード例 #25
0
ファイル: EtoEnvironment.cs プロジェクト: Exe0/Eto
		public static string GetFolderPath (Generator g, EtoSpecialFolder folder)
		{
			return GetFolderPath (folder, g);
		}
コード例 #26
0
ファイル: EtoEnvironment.cs プロジェクト: daddycoding/Eto
        public static string GetFolderPath(EtoSpecialFolder folder, Generator generator)
        {
            var handler = generator.CreateShared <IHandler>();

            return(handler.GetFolderPath(folder));
        }
コード例 #27
0
ファイル: EtoEnvironment.cs プロジェクト: majorsilence/Eto
		/// <summary>
		/// Gets the folder path for the specified special folder
		/// </summary>
		/// <param name="folder">Special folder to retrieve the path for</param>
		/// <returns>Path of the specified folder</returns>
		public static string GetFolderPath (EtoSpecialFolder folder)
		{
			return GetFolderPath(Generator.Current, folder);
		}
コード例 #28
0
ファイル: EtoEnvironment.cs プロジェクト: Exe0/Eto
		/// <summary>
		/// Gets the folder path for the specified special folder
		/// </summary>
		/// <param name="folder">Special folder to retrieve the path for</param>
		/// <param name="generator">Generator to get the folder path with</param>
		/// <returns>Path of the specified folder</returns>
		public static string GetFolderPath (EtoSpecialFolder folder, Generator generator = null)
		{
			var handler = generator.CreateShared<IEtoEnvironment> ();
			return handler.GetFolderPath (folder);
		}
コード例 #29
0
        /// <summary>
        /// Gets the folder path for the specified special folder
        /// </summary>
        /// <param name="folder">Special folder to retrieve the path for</param>
        /// <returns>Path of the specified folder</returns>
        public static string GetFolderPath(EtoSpecialFolder folder)
        {
            var handler = Eto.Platform.Instance.CreateShared <IHandler>();

            return(handler.GetFolderPath(folder));
        }