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


C# FileInfo.Split方法代码示例

本文整理汇总了C#中System.IO.FileInfo.Split方法的典型用法代码示例。如果您正苦于以下问题:C# FileInfo.Split方法的具体用法?C# FileInfo.Split怎么用?C# FileInfo.Split使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.IO.FileInfo的用法示例。


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

示例1: loadPlugin

        public Plugin loadPlugin(string PluginPath)
        {
            try
            {
                string name = new FileInfo(PluginPath).Name;
                Assembly pluginAssembly = Assembly.LoadFrom(PluginPath);
                if (name.Contains("."))
                {
                    name = name.Split('.')[0];
                }

                Type pluginType = pluginAssembly.GetType(name + "." + name);
                Plugin plugin = (Plugin)Activator.CreateInstance(pluginType);
                if (plugin == null)
                {
                    Console.WriteLine("Error Loading Plugin '" + PluginPath + "'. Is it up to Date?");
                }
                else
                {
                    plugin.Server = server;
                    plugin.Load();
                    return plugin;
                }
            }
            catch (Exception exception)
            {
                Console.WriteLine("Error Loading Plugin '" + PluginPath + "' : "
                    + exception.ToString());
            }

            return null;
        }
开发者ID:rasmussaks,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:32,代码来源:PluginManager.cs

示例2: CreateNameFromPath

 string CreateNameFromPath(string path)
 {
     var name = new FileInfo(path).Name;
     var parts = name.Split(new[] { '_' });
     if(parts.Length != 4)
         throw new Exception("Invalid Version found");
     return String.Format("v.{0}  {1}  {2}", parts[1], new DateTime(long.Parse(parts[2])), parts[3].Replace(".xml", ""));
 }
开发者ID:NatashaSchutte,项目名称:Warewolf-ESB,代码行数:8,代码来源:ServerVersionRepository.cs

示例3: CreateVersionInfoFromFilePath

 IVersionInfo CreateVersionInfoFromFilePath(string path, Guid resourceId)
 {
     var name = new FileInfo(path).Name;
     var parts = name.Split(new[] { '_' });
     if(parts.Length != 4)
         throw new Exception("Invalid Version found");
     return new VersionInfo(new DateTime(long.Parse(parts[2])), parts[3], "", parts[1], resourceId, Guid.Parse(parts[0]));
 }
开发者ID:NatashaSchutte,项目名称:Warewolf-ESB,代码行数:8,代码来源:ServerVersionRepository.cs

示例4: Loadplugin

        /// <summary>
        ///     Loads the plugin.yml file of a .jar plugin
        /// </summary>
        /// <param name="path">the path of the plugin.jar file</param>
        /// <param name="readCache">if this plugin should be read from cache if possible</param>
        /// <returns>The InstalledPlugin (me)</returns>
        /// <remarks></remarks>
        public InstalledPlugin Loadplugin(string path, bool readCache = true)
        {
            try
            {
                // to reduce load times and CPU usage, plugin.yml files are cached
                // location: cache/plugins/plugin_name/plugin.yml

                // Detect reletive locations and prepend thise with the plugin dir

                if (path.Contains(":\\") == false) // has to start with C:\ (\\ due to escaping special characters)
                    path = Fl.Location(RequestFile.Plugindir) + "\\" + path;

                // get a fileinfo object for the plugin
                FileInfo plugFileInfo = new FileInfo(path);

                // get a fileinfo object for the cache
                FileInfo cacheFileInfo =
                    new FileInfo(Fl.Location(RequestFile.Cache) + "/plugins/" + plugFileInfo.Name + "/plugin.yml");

                Logger.Log(LogLevel.Info, "InstalledPlugin",
                    "loading plugin (step 1/2): " + plugFileInfo.Name + " - cache allowed:" + readCache);

                //check if the cache exists, if not, create cache (we need this cache file, it will be read later on)
                if (cacheFileInfo.Exists & readCache)
                {
                    // cache exists, ok
                    Logger.Log(LogLevel.Info, "InstalledPlugin", "Reading plugin data from cache...");
                }
                else
                {
                    // cache doesn't exist or is forcefully invalidated by parameter, create

                    //safety check
                    if (string.IsNullOrEmpty(path) || plugFileInfo.Exists == false)
                    {
                        return null;
                    }

                    Logger.Log(LogLevel.Info, "InstalledPlugin",
                        "Plugin data not available in cache or cache not allowed. Building cache for plugin...");
                    Compression.Decompress(Fl.Location(RequestFile.Temp) + "/plugin", path);

                    // check if the plugin.yml file was decompressed
                    if (!File.Exists(Fl.Location(RequestFile.Temp) + "/plugin/plugin.yml"))
                    {
                        return null;
                    }

                    if (cacheFileInfo.Directory != null && !cacheFileInfo.Directory.Exists) cacheFileInfo.Directory.Create();
                    //copy the yml to cache
                    File.Copy(Fl.Location(RequestFile.Temp) + "/plugin/plugin.yml", cacheFileInfo.FullName, true);
                    if (Directory.Exists(Fl.Location(RequestFile.Temp) + "/plugin"))
                        Directory.Delete(Fl.Location(RequestFile.Temp) + "/plugin", true);
                }
                // either way is cache now okay, it already existed or was created just now
                Logger.Log(LogLevel.Info, "InstalledPlugin",
                    "loading plugin (step 2/2): " + plugFileInfo.Name + " - cache allowed:" + readCache);

                // load the yml file
                if (File.Exists(cacheFileInfo.FullName))
                    Loadymlfile(cacheFileInfo.FullName);

                FileCreationDate = File.GetLastWriteTime(path);
                FileName = new FileInfo(path).Name;

                if (Name == null || string.IsNullOrEmpty(Name) && FileName.Contains("."))
                    Name = FileName.Split('.')[0];
                //if name couldn't be read from yml, parse FileName

                Logger.Log(LogLevel.Info, "InstalledPlugin",
                    "loaded plugin: " + plugFileInfo.Name + " - cache allowed:" + readCache);

                return this;
                //return this item
            }
            catch (Exception ex)
            {
                Logger.Log(LogLevel.Warning, "InstalledPlugin", "An exception occured when trying to load plugin",
                    ex.Message);
                return null;
            }
        }
开发者ID:AnonymousDeviser,项目名称:bukkitgui2,代码行数:89,代码来源:InstalledPlugin.cs

示例5: getInstance

        /// <summary>
        /// 创建Orc实例(from Directory)
        /// </summary>
        /// <param name="offsetX"></param>
        /// <param name="offsetY"></param>
        /// <param name="width"></param>
        /// <param name="height"></param>
        /// <param name="resource"></param>
        /// <returns></returns>
        public static OrcUtil getInstance(int[] offsetX, int offsetY, int width, int height, String dictPath)
        {
            OrcUtil rtn = new OrcUtil();
            rtn.offsetX = offsetX;
            rtn.offsetY = offsetY;
            rtn.width = width;
            rtn.height = height;
            rtn.dict = new Dictionary<Bitmap, String>();

            String[] files = System.IO.Directory.GetFiles(dictPath);
            foreach (String file in files)
            {
                String name = new System.IO.FileInfo(file).Name;
                String[] array = name.Split(new char[] { '.' });
                Bitmap bitmap = new Bitmap(file);
                rtn.dict.Add(bitmap, array[0]);
            }
            return rtn;
        }
开发者ID:CapricornZ,项目名称:autobid,代码行数:28,代码来源:OrcUtil.cs

示例6: ProcessFlyspeckLP

        /// <summary>
        /// Processes all Flyspeck linear programs in the current directory
        /// </summary>
        static void ProcessFlyspeckLP()
        {
            ListHypManager hypermaps = InitializeHypermaps();

            // GenerateExamples();
            string[] files = Directory.GetFiles(".", "*.lp");
            FileStream fs = new FileStream("all_tests.hl", FileMode.Create);
            StreamWriter w = new StreamWriter(fs);

            w.WriteLine("let start = Sys.time();;");

            int i = 1;
            foreach (string file in files)
            {
                string name = new FileInfo(file).Name;
                string[] els = name.Split('.');
                ListHyp hypermap = hypermaps[els[0]];
                hypermap.ComputeAllSets();

                ProcessLP(els[0], new LpNumber(12), hypermap);

                w.WriteLine("\"Case: {0}/{1}\";;", i++, files.Length);
                w.WriteLine("let _ = needs \"{0}\" in Sys.time() -. start;;", els[0] + "_out.hl");
                // break;
            }

            w.Flush();
            fs.Close();
        }
开发者ID:JUrban,项目名称:flyspeck-git-svn,代码行数:32,代码来源:Program.cs


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