ALFA.SystemInfo.GetHomeDirectory C# (CSharp) Метод

GetHomeDirectory() публичный статический Метод

This routine gets the NWN2 "Home" directory, which is the directory name by -home on the command line, or else the user's NWN2 directory under Documents.
public static GetHomeDirectory ( ) : string
Результат string
        public static string GetHomeDirectory()
        {
            string[] Args = Environment.GetCommandLineArgs();

            for (int i = 0; i < Args.Length; i += 1)
            {
                if (Args[i] == "-home" && i + 1 < Args.Length)
                    return Args[i + 1] + "\\";
            }

            return Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\Neverwinter Nights 2\\";
        }

Usage Example

Пример #1
0
        /// <summary>
        /// This method performs demand loading of resource repositories.
        /// </summary>
        /// <param name="ModuleOnly">If true, only load the module core
        /// resources.</param>
        private void LoadResourceRepositories(bool ModuleOnly)
        {
            string HomeDirectory    = SystemInfo.GetHomeDirectory();
            string InstallDirectory = SystemInfo.GetGameInstallationDirectory();
            string ModPath;
            string DataPath;

            //
            // Create a dummy resource manager to keep OEIShared happy.  We do
            // not use it explicitly, but some OEIShared code uses
            // ResourceManager.Instance and hopes to get something back.
            //

            if (OEIShared.IO.ResourceManager.Instance == null)
            {
                new DummyOEIResourceManager();
            }

            if (ModuleResourceName == null)
            {
                ModuleResourceName = SystemInfo.GetModuleResourceName();
            }

            if (ModuleResourceName == null)
            {
                throw new ApplicationException("Cannot determine module resource name.");
            }

            Repositories = new List <ResourceRepository>();

            ModPath = String.Format("{0}\\modules\\{1}.mod", HomeDirectory, ModuleResourceName);

            if (File.Exists(ModPath))
            {
                Repositories.Add(new ALFAERFResourceRepository(ModPath));
            }
            else
            {
                ModPath = String.Format("{0}\\modules\\{1}\\", HomeDirectory, ModuleResourceName);

                Repositories.Add(new DirectoryResourceRepository(ModPath));
            }

            if (!ModuleOnly)
            {
                GFFFile ModuleIfo = OpenModuleIfo();

                AddModuleHaks(ModuleIfo, HomeDirectory, InstallDirectory);
                AddModuleCampaign(ModuleIfo, HomeDirectory, InstallDirectory);

                foreach (string PathName in new string[] { HomeDirectory, InstallDirectory })
                {
                    string overrideFolder = String.Format("{0}\\override", PathName);
                    if (Directory.Exists(overrideFolder))
                    {
                        Repositories.Add(new DirectoryResourceRepository(overrideFolder));
                    }
                }

                DataPath = String.Format("{0}\\Data", InstallDirectory);

                foreach (string ZipPath in Directory.EnumerateFiles(DataPath, "*.zip"))
                {
                    Repositories.Add(new ZIPResourceRepository(ZipPath));
                }
            }

            //
            // Finally, populate all of the repositories, which may take time.
            //

            foreach (ResourceRepository Repository in Repositories)
            {
                Repository.PopulateRepository();
            }
        }