當前位置: 首頁>>代碼示例>>C#>>正文


C# DirectoryInfo.Split方法代碼示例

本文整理匯總了C#中System.IO.DirectoryInfo.Split方法的典型用法代碼示例。如果您正苦於以下問題:C# DirectoryInfo.Split方法的具體用法?C# DirectoryInfo.Split怎麽用?C# DirectoryInfo.Split使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.IO.DirectoryInfo的用法示例。


在下文中一共展示了DirectoryInfo.Split方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: UpdateFoldersInPath

        private void UpdateFoldersInPath(string directory)
        {
            // look for a date in the folder name and change it if the year does not match
            DateTime existingFolderDate;

            string folderName = new DirectoryInfo(directory).Name;

            if (DateTime.TryParse(folderName.Split(' ').First(), out existingFolderDate))
            {

                Logger.Log("Found date in folder name: " + existingFolderDate + " for " + directory);
                // get date of all photos
                var files = Directory.GetFiles(directory, "*.*", SearchOption.TopDirectoryOnly);
                foreach (string file in files)
                {
                    //Logger.Log(file);
                    DateTime originalFileTime = Directory.GetCreationTime(file);
                    if (originalFileTime.Subtract(existingFolderDate).Days > minNumDaysDiff)
                    {
                        Logger.Log(String.Format("Change {0} to {1} for {2}", originalFileTime, existingFolderDate, file));
                        File.SetCreationTime(file, existingFolderDate);
                        File.SetLastWriteTime(file, existingFolderDate);
                    }
                }
            }

            string[] directories = Directory.GetDirectories(directory);

            foreach (string subFolder in directories)
            {
                UpdateFoldersInPath(subFolder);
            }
        }
開發者ID:janhebnes,項目名稱:ImageLibraryRenamer,代碼行數:33,代碼來源:GetFileDateFromFolderName.cs

示例2: MainWindow

        public MainWindow()
        {
            InitializeComponent();

            briefing = new Briefing();
            installHandler = new InstallHandler(this, briefing);
            VisibilityHandler = new VisibilityHandler(this);
            VisibilityHandler.showProfileSettings();

            TextBox_Briefing_Text.IsReadOnly = false;
            TextBox_Briefing_Text.AcceptsReturn = true;

            // Get arma profilefolders
            String arma3Folder = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + @"\Arma 3";
            String arma3OtherFolder = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + @"\Arma 3 - Other Profiles";

            // Find default arma profilename
            if (Directory.Exists(arma3Folder))
            {
                string[] files = Directory.GetFiles(arma3Folder, "*.Arma3Profile");

                string filename = new DirectoryInfo(files[0]).Name;
                string[] names = filename.Split('.');

                Combobox_Profile_Name.Items.Add(names[0]);
            }

            // Find all custom arma profilenames
            if (Directory.Exists(arma3OtherFolder))
            {
                string[] subdirectoryEntries = Directory.GetDirectories(arma3OtherFolder);
                foreach (string subdirectory in subdirectoryEntries)
                {
                    Combobox_Profile_Name.Items.Add(new DirectoryInfo(subdirectory).Name);
                }

            }

            // Set all combobox to first value
            ComboBox_Briefing_Side.SelectedIndex = 0;
            ComboBox_Briefing_Title.SelectedIndex = 0;
            Combobox_Mission_Gametype.SelectedIndex = 0;
            Combobox_Profile_Name.SelectedIndex = 0;
            Combobox_Mission_Map.SelectedIndex = 0;
            Combobox_Profile_Editor.SelectedIndex = 0;
        }
開發者ID:nikolauska,項目名稱:Kuikka_Installer_GUI_2,代碼行數:46,代碼來源:MainWindow.xaml.cs

示例3: GetVendorForGnu

        protected npandaySettingsVendorsVendor GetVendorForGnu(String libPath)
        {
            if (libPath == null)
                throw new ExecutionException("NPANDAY-9011-000: Could not detect GNU vendor: No CSCC_LIB_PATH Found");

            if (libPath.EndsWith("lib" + Path.DirectorySeparatorChar + "cscc" + Path.DirectorySeparatorChar + "lib"))
            {
                string installR = new DirectoryInfo(libPath).Parent.Parent.Parent.FullName;
                string[] tokenizedInstallRoot = installR.Split(Path.DirectorySeparatorChar);
                string vendorVersion = tokenizedInstallRoot[tokenizedInstallRoot.Length - 1];
                if (!isValidVersion(vendorVersion))
                {
                    throw new ExecutionException("NPANDAY-9011-001: Invalid version format for dotGNU: Version = " +
                        vendorVersion + ", Root = " + installR);
                }

                npandaySettingsVendorsVendor vendor = new npandaySettingsVendorsVendor();
                vendor.vendorName = "DotGNU";
                vendor.vendorVersion = vendorVersion;
                npandaySettingsVendorsVendorFrameworksFramework[] vendorFrameworks
                    = new npandaySettingsVendorsVendorFrameworksFramework[1];
                npandaySettingsVendorsVendorFrameworksFramework vf = new npandaySettingsVendorsVendorFrameworksFramework();
                vf.installRoot = Path.Combine(installR, "bin");
                vf.frameworkVersion = "2.0.50727";//doesn't matter
                vendorFrameworks[0] = vf; ;
                vendor.frameworks = vendorFrameworks;
                return vendor;
            }
            throw new ExecutionException("NPANDAY-9011-002: CSCC_LIB_PATH found but could not determine vendor information");
        }
開發者ID:tocsleung,項目名稱:npanday,代碼行數:30,代碼來源:SettingsGeneratorMojo.cs


注:本文中的System.IO.DirectoryInfo.Split方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。