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


C# FileInfo.Contains方法代码示例

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


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

示例1: BumpAssemblyFile

        public void BumpAssemblyFile()
        {
            AssemblyBumper.BumpIt(new FileInfo(@".\TestInputs\Project1\Properties\AssemblyInfo.cs"), 9, 9, 9, 9);

            string content = new FileInfo(@".\TestInputs\Project1\Properties\AssemblyInfo.cs").OpenText().ReadToEnd();
            Assert.IsTrue(content.Contains(@"[assembly: AssemblyVersion(""9.9.9.9"")]"));
            Assert.IsTrue(content.Contains(@"[assembly: AssemblyFileVersion(""9.9.9.9"")]"));
        }
开发者ID:Vinzz,项目名称:VersionBumper.NET,代码行数:8,代码来源:BumpAssemblyInfoTest.cs

示例2: GetSafeAbsolutePath

        public static string GetSafeAbsolutePath(string relativeFileName)
        {
            string Result = "";

            try
            {
                // Get absolute path for the given relative path
                string SavedCurrentDirectory = Environment.CurrentDirectory;
                Environment.CurrentDirectory = ProcessUtils.StartupPath;
                string AbsoluteFileName = new FileInfo(relativeFileName).FullName;
                Environment.CurrentDirectory = SavedCurrentDirectory;

                if (AbsoluteFileName.Contains(ProcessUtils.StartupPath))
                {
                    // Path is in the LORD2 directory (or a subdirectory), so lowercase the filename so we don't have mixed case usage (for Linux)
                    string Directory = Path.GetDirectoryName(AbsoluteFileName);
                    string FileName = Path.GetFileName(AbsoluteFileName).ToLower();
                    Result = StringUtils.PathCombine(Directory, FileName);
                }
            }
            catch
            {
                // Ignore, we'll return the default ""
            }

            return Result;
        }
开发者ID:rickparrish,项目名称:LORD2,代码行数:27,代码来源:Global.cs

示例3: Download

 /// <summary>
 /// Download the MPQ Files which are in nodeList and not in mpqFiles
 /// </summary>
 /// <param name="nodeList">Node List existing in version.xml</param>
 /// <param name="mpqFiles">MPQ Files existing in Data/ directory</param>
 /// <param name="dataDir">Absolute path to Data/ directory</param>
 public void Download(XmlNodeList nodeList, FileInfo[] mpqFiles, string dataDir)
 {
     DialogResult result = MessageBox.Show("Une nouvelle mise à jour a été trouvée !\r\n Télécharger ?", "Avertissement", MessageBoxButtons.OKCancel);
     if (result == DialogResult.Cancel)
     {
         Close();
     }
     else
     {
         foreach (XmlNode node in nodeList)
         {
             if (!mpqFiles.Contains(new FileInfo(node.InnerText)))
             {
                 // Have to create two WebClient
                 WebClient webClient = new WebClient();
                 WebClient webClient2 = new WebClient();
                 labelDl.Text = "Téléchargement de la mise à jour : " + node.Attributes["nom"].Value;
                 webClient.DownloadProgressChanged += new DownloadProgressChangedEventHandler(webClient_DownloadProgressChanged);
                 webClient2.DownloadStringCompleted += new DownloadStringCompletedEventHandler(webClient2_DownloadStringCompleted);
                 webClient2.DownloadStringAsync(new Uri(node.Attributes["desc"].Value));
                 webClient.DownloadFileAsync(new Uri(node.Attributes["lien"].Value), Path.Combine(dataDir, node.InnerText));
             }
         }
         buttonClose.Visible = true;
     }
 }
开发者ID:pauljenny,项目名称:Launcher,代码行数:32,代码来源:DownloaderBox.cs

示例4: 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

示例5: BumpAssemblyFile

        public void BumpAssemblyFile()
        {
            WXSBumper.BumpIt(new FileInfo(@".\TestInputs\Project3\Product.wxs"), 9, 9, 9, 9);

            string content = new FileInfo(@".\TestInputs\Project3\Product.wxs").OpenText().ReadToEnd();

            Assert.IsTrue(content.Contains(@"Version=""9.9.9.9"""));
        }
开发者ID:Vinzz,项目名称:VersionBumper.NET,代码行数:8,代码来源:BumpProductWXSTest.cs

示例6: GetHTML

        public String GetHTML()
        {
            String email = Resource1.Email;
            try
            {
                String shortName = new FileInfo(Filename).Name;
                String typArq = shortName.Substring(shortName.IndexOf("ACCC"), 7);
                String sTypArq = Utils.GetTypArq(typArq);

                email = email.Replace(MAIL_NOMARQ, shortName);
                email = email.Replace(MAIL_TIPARQ, typArq + " - " + sTypArq);
                email = email.Replace(MAIL_TAMARQ, Tamanho.ToString("F2") + " MB");
                email = email.Replace(MAIL_PRO, shortName.Contains("PRO.xml") ? "Sim" : "N&atilde;o");

                StringBuilder sb = new StringBuilder();

                //header
                sb.AppendLine(String.Format(MAIL_LINHA_HDR, "Cabe&ccedil;alho"));
                foreach (KeyValuePair<String, String> dado in Header)
                {
                    String value = dado.Value;
                    if (!value.Equals(String.Empty))
                    {
                        sb.AppendLine(String.Format(MAIL_LINHADADO_HDR, dado.Key, dado.Value));
                    }
                }
                //body
                sb.AppendLine(String.Format(MAIL_LINHA_HDR, "Dados"));
                foreach (KeyValuePair<String, String> dado in Body)
                {
                    sb.AppendLine(String.Format(MAIL_LINHADADO, dado.Key, dado.Value));
                }
                email = email.Replace(MAIL_DADOSARQ, sb.ToString());
            }
            catch (Exception ex)
            {
                if (Utils._logger != null)
                    Utils._logger.Error("Erro ao construir o body do email." + ex.Message);
            }
            return email;
        }
开发者ID:GregXP,项目名称:XP,代码行数:41,代码来源:ACCCxxx.cs

示例7: 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

示例8: AddProjectInclude

        public async Task<bool> AddProjectInclude(string containerDirectory, string scriptFile = null)
        {
            if (!Project.Saved)
            {
                var saveDialogResult = MessageBox.Show(_ownerWindow, "Save pending changes to solution?",
                    "Save pending changes", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (saveDialogResult == DialogResult.OK || saveDialogResult == DialogResult.Yes)
                    _dte.SaveAll();
            }
            if (!Project.Saved || string.IsNullOrEmpty(Project.FullName))
            {
                var saveDialogResult = MessageBox.Show(_ownerWindow, "Pending changes need to be saved. Please save the project before adding project imports, then retry.", "Save first",
                    MessageBoxButtons.OKCancel, MessageBoxIcon.Asterisk);
                if (saveDialogResult != DialogResult.Cancel) _dte.SaveAll();
                return false;
            }
            _logger.LogInfo("Begin adding project import file");
            if (string.IsNullOrWhiteSpace(containerDirectory))
                containerDirectory = Project.GetDirectory();

            if (string.IsNullOrWhiteSpace(scriptFile))
            {
                _logger.LogInfo("Prompting for file name");
                var dialog = new AddBuildScriptNamePrompt(containerDirectory, ".targets")
                {
                    HideInvokeBeforeAfter = true
                };
                var dialogResult = dialog.ShowDialog(VsEnvironment.OwnerWindow);
                if (dialogResult == DialogResult.Cancel) return false;
                scriptFile = dialog.FileName;
                _logger.LogInfo("File name chosen: " + scriptFile);
                dialogResult = MessageBox.Show(_ownerWindow, @"        !! IMPORTANT !!

You must not move, rename, or remove this file once it has been added to the project. By adding this file you are extending the project file itself. If you must change the filename or location, you must update the project XML directly where <Import> references it.",
                    "This addition is permanent", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
                if (dialogResult == DialogResult.Cancel) return false;
            }
            var scriptFileName = scriptFile;
            if (!scriptFile.Contains(":") && !scriptFile.StartsWith("\\\\"))
                scriptFile = Path.Combine(containerDirectory, scriptFile);
            var scriptFileRelativePath = FileUtilities.GetRelativePath(Project.GetDirectory(), scriptFile);
            var scriptFileShortName = new FileInfo(scriptFile).Name;
            if (scriptFileShortName.Contains("."))
                scriptFileShortName = scriptFileShortName.Substring(0, scriptFileShortName.LastIndexOf("."));

            if (Project == null) return false;

            File.WriteAllText(scriptFile, @"<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
    <Target Name=""" + scriptFileShortName + @"""><!-- consider adding attrib BeforeTargets=""Build"" or AfterTargets=""Build"" -->

        <!-- my tasks here -->
        <Message Importance=""high"" Text=""" + scriptFileShortName + @".targets output: ProjectGuid = $(ProjectGuid)"" />

    </Target>
</Project>");
            var projRoot = Project.GetProjectRoot();
            var import = projRoot.AddImport(scriptFileRelativePath);
            import.Condition = "Exists('" + scriptFileRelativePath + "')";
            Project = await Project.SaveProjectRoot();
            var addedItem = Project.ProjectItems.AddFromFile(scriptFile);
            addedItem.Properties.Item("ItemType").Value = "None";
            _logger.LogInfo("Project include file added to project: " + scriptFileName);
            Task.Run(() =>
            {
                System.Threading.Thread.Sleep(250);
                _dte.ExecuteCommand("File.OpenFile", "\"" + scriptFile + "\"");
            });
            return true;
        }
开发者ID:freeart,项目名称:FastKoala,代码行数:69,代码来源:TargetsScriptInjector.cs

示例9: GetSelectedText

        private void GetSelectedText()
        {
            int activeWinPtr = GetForegroundWindow().ToInt32();
               int activeThreadId = 0, processId;
               activeThreadId = GetWindowThreadProcessId(activeWinPtr, out processId);
               int currentThreadId = GetCurrentThreadId();
               //String prev = txtCmdLine.Text;
               if (activeThreadId != currentThreadId)
               {
               AttachThreadInput(activeThreadId, currentThreadId, true);
               SendCtrlC();
               System.Threading.Thread.Sleep(10);
               AttachThreadInput(activeThreadId, currentThreadId, false);
               ShowHide();
               if (Clipboard.ContainsText())
               {
                        HandleCmd(CmdInvoker.InvokeCommand("a "+Clipboard.GetText().Replace(Environment.NewLine," ")));
               }
               else if (Clipboard.ContainsFileDropList())
               {
                   for (int i = 0; i < Clipboard.GetFileDropList().Count; i++)
                   {
                       GGResult r;
                       String f = new FileInfo(Clipboard.GetFileDropList()[i]).Name;
                       if (f.Contains('.')) f = f.Substring(0, f.LastIndexOf('.'));
                       r = CmdInvoker.InvokeCommand("a \"" + f + "\"");
                       GGItem gg = CmdInvoker.GetGGList().GetGGItemAt(r.GetItemIndex());
                       HandleCmd(r);
                       HandleCmd(CmdInvoker.InvokeCommand("pin " + (CmdInvoker.GetGGList().IndexOfGGItem(gg) + 1) + " " + Clipboard.GetFileDropList()[i]));

                   }
               }
               //if (txtCmdLine.Text.Equals("a ")) txtCmdLine.Text = prev;
               }
        }
开发者ID:wertkh32,项目名称:gg,代码行数:35,代码来源:MainWindow.xaml.cs

示例10: file_to_context

        private ui_context file_to_context(string name)
        {
            string from_header = log_to_default_context.file_to_context(name);
            if (from_header != null) {
                var context_from_header = contexts_.FirstOrDefault(x => x.name == from_header);
                if (context_from_header != null)
                    // return it, only if we have a specific Template for it
                    return context_from_header;
            }

            string file_name_no_dir = new FileInfo(name).Name;
            var found = contexts_.FirstOrDefault(x => file_name_no_dir.Contains( x.name));
            if (found != null)
                return found;

            var default_ = contexts_.FirstOrDefault(x => x.name == "Default");
            return default_ ?? contexts_[0];
        }
开发者ID:mcintosh,项目名称:logwizard,代码行数:18,代码来源:log_wizard.cs


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