当前位置: 首页>>代码示例>>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;未经允许,请勿转载。