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


C# FileInfo.StartsWith方法代码示例

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


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

示例1: GetAllProjects

        /// <summary>
        /// In the given path and all folders below it, load all valid projects, currently only .csproj files
        /// </summary>
        /// <param name="SearchPath"></param>
        /// <returns></returns>
        public ProjectList GetAllProjects()
        {
            //return list of projects
            ProjectList projects = new ProjectList();
            Console.WriteLine("start to fetch .csproj files");
            //get list of all csproj files below current directory
            string[] FilePaths = Directory.GetFiles(SearchPath, "*.csproj", SearchOption.AllDirectories);
            foreach (string FilePath in FilePaths)
            {
                if (!FilePath.ToLower().Contains("mainline") && MainLineOnly.ToUpper().Equals("T"))
                    continue;
                else
                {
                    string FileName = new FileInfo(FilePath).Name;

                    //if not a unit test (Test or UnitTest.csproj, then add it
                    //TODO: refactor to allow exclusions to be passed in?
                    if (!FileName.StartsWith("Test") && !FileName.StartsWith("UnitTest"))
                    {
                        Console.WriteLine(string.Format("Adding project {0} ...", FilePath));
                        projects.Add(new Project(FilePath));
                    }
                }
            }
            return projects;
        }
开发者ID:pugong,项目名称:DependencyTracker,代码行数:31,代码来源:DependencyFinder.cs

示例2: RemoveAssembliesFromGac

        public static void RemoveAssembliesFromGac(string searchPattern)
        {
            var assemblyPaths = GetGacAssemblyPaths(searchPattern);
            var backupPath = Path.Combine(Environment.CurrentDirectory, @"GAC_Backup");

            foreach (var assemblyPath in assemblyPaths)
            {
                // For safety, only allow files with a "MEDSEEK" or "Agatha" prefix to be removed from GAC
                var fileName = new FileInfo(assemblyPath).Name;

                if (fileName.StartsWith("MEDSEEK", StringComparison.OrdinalIgnoreCase) || fileName.StartsWith("Agatha", StringComparison.OrdinalIgnoreCase))
                {
                    LoggingUtils.WriteInfo(string.Format(CultureInfo.InvariantCulture, "Removing assembly ({0}) from GAC", fileName));

                    // Backup assembly
                    BackupAssembly(assemblyPath, backupPath);

                    // Remove assembly from GAC
                    var publisher = new System.EnterpriseServices.Internal.Publish();
                    publisher.GacRemove(assemblyPath);
                }
                else
                    LoggingUtils.WriteWarn(string.Format(CultureInfo.InvariantCulture, "Skipping removal of non-MEDSEEK assembly ({0}) from GAC", fileName));
            }

            LoggingUtils.WriteInfo(string.Format(CultureInfo.InvariantCulture, "GAC assemblies backed up to: ({0})", backupPath), ConsoleColor.Green);
        }
开发者ID:rickeygalloway,项目名称:Test,代码行数:27,代码来源:GacUtils.cs

示例3: FilePaths

        static FilePaths()
        {
            _programDirectory = new FileInfo(Application.ResourceAssembly.Location).DirectoryName;

            string pfiles = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86);
            _writeToAppData = _programDirectory.StartsWith(pfiles) || !CheckWritePermissions(Path.Combine(_programDirectory,"writecheck.txt"));

            _AppDataPath = System.IO.Path.GetFullPath(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\NanoTrans");

            CreateTemp();
        }
开发者ID:Ttxman,项目名称:NanoTrans,代码行数:11,代码来源:FilePaths.cs

示例4: GetDatasets

 public static string[] GetDatasets(string root)
 {
   var subdirs = Directory.GetDirectories(root);
   Array.Sort(subdirs, delegate(string name1, string name2)
   {
     var n1 = new FileInfo(name1).Name;
     var n2 = new FileInfo(name2).Name;
     if (n1.StartsWith("GSE") && n2.StartsWith("GSE"))
     {
       return int.Parse(n1.Substring(3)).CompareTo(int.Parse(n2.Substring(3)));
     }
     else
     {
       return name1.CompareTo(name2);
     }
   });
   return subdirs;
 }
开发者ID:shengqh,项目名称:CQS.Core,代码行数:18,代码来源:SampleUtils.cs

示例5: SendFile

        public static void SendFile(string path, HttpListenerContext context)
        {
            var ext = new FileInfo(path).Extension;
            if (ext.StartsWith("."))
                ext = ext.Remove(0, 1);
            context.Response.ContentType = getContentType(ext);

            byte[] buffer;

            if (context.Response.ContentType == "text/html" || context.Response.ContentType == "text/javascript" || context.Response.ContentType == "text/css")
            {
                using (var rdr = File.OpenText(path))
                {
                    var send = rdr.ReadToEnd();

                    if (ext == "php")
                    {
                        Process p = new Process();
                        p.StartInfo = new ProcessStartInfo("php\\php-cgi.exe", $"-f {path} {GetPhpArgumentQuery(context.Request.QueryString)}")
                        {
                            UseShellExecute = false,
                            RedirectStandardInput = true,
                            RedirectStandardOutput = true,
                            WindowStyle = ProcessWindowStyle.Hidden
                        };
                        p.Start();
                        send = p.StandardOutput.ReadToEnd();
                    }

                    foreach (var toReplace in replaceVars)
                    {
                        var tmp = String.Empty;
                        if (toReplace.Value.StartsWith("PATH"))
                        {
                            using (var r = File.OpenText(toReplace.Value.Split(':')[1]))
                                tmp = r.ReadToEnd();

                            send = send.Replace(toReplace.Key, tmp);
                        }
                        else if (toReplace.Value.StartsWith("PROPERTYCALL"))
                        {
                            var property = context.Request.GetType().GetProperty(toReplace.Value.Split(':')[1]);
                            if (property != null)
                                send = send.Replace(toReplace.Key, property.GetValue(context.Request).ToString());
                        }
                        else
                            send = send.Replace(toReplace.Key, toReplace.Value);
                    }
                    buffer = Encoding.UTF8.GetBytes(send);
                }
            }
            else
            {
                using (Stream s = File.OpenRead(path))
                {
                    buffer = new byte[s.Length];
                    var length = s.Read(buffer, 0, (int)s.Length);
                    Array.Resize(ref buffer, length);
                }
            }
            context.Response.StatusCode = 200;
            context.Response.StatusDescription = "OK";
            context.Response.ContentLength64 = buffer.Length;
            context.Response.OutputStream.Write(buffer, 0, buffer.Length);
        }
开发者ID:SirAnuse,项目名称:fabiano-swagger-of-doom,代码行数:65,代码来源:Program.cs

示例6: GenerateContent

        internal string GenerateContent(string templateFilename, string targetFilename, NameValueCollection overrideArguments)
        {
            DTE vs = this.GetService<DTE>(true);

              string templateCode = string.Empty;
              if (templateFilename == null)
              {
            throw new ArgumentNullException("Template");
              }
              string templateBasePath = this.GetTemplateBasePath();
              if (!Path.IsPathRooted(templateFilename))
              {
            templateFilename = Path.Combine(templateBasePath, templateFilename);
              }
              if (!File.Exists(templateFilename))
              {
            throw new FileNotFoundException(templateFilename);
              }
              templateFilename = new FileInfo(templateFilename).FullName;
              if (!templateFilename.StartsWith(templateBasePath))
              {
            throw new ArgumentException("Starts not with " + templateBasePath);
              }
              templateCode = File.ReadAllText(templateFilename);

              //jetzt alle properties rein
              StringBuilder templateCodeLines = new StringBuilder();
              StringReader reader = new StringReader(templateCode);
              string line = "";
              bool firstlinefound = false;
              bool itemadded = false;
              while ((line = reader.ReadLine()) != null)
              {
            if (firstlinefound && !itemadded)
            {
              itemadded = true;
              AddTargetFileNameArgument(templateCodeLines, targetFilename);
              AddAllArguments(templateCodeLines, overrideArguments);
            }
            if (line.StartsWith("<#@ template language="))
            {
              firstlinefound = true;
            }
            templateCodeLines.AppendLine(line);
              }

              return this.Render(templateCodeLines.ToString(), templateFilename);
        }
开发者ID:sunday-out,项目名称:SharePoint-Software-Factory,代码行数:48,代码来源:BaseItemAction.cs

示例7: Execute

 // Methods
 public override void Execute()
 {
     if (!String.IsNullOrEmpty(this.templateExpression))
     {
         this.Template = (string)ExpressionEvaluationHelper.EvaluateExpression(
                         (IDictionaryService)GetService(typeof(IDictionaryService)),
                         this.templateExpression);
     }
     string path = this.Template;
     string templateCode = string.Empty;
     if (path == null)
     {
         throw new ArgumentNullException("Template");
     }
     string templateBasePath = base.GetTemplateBasePath();
     if (!Path.IsPathRooted(path))
     {
         path = Path.Combine(templateBasePath, path);
     }
     path = new FileInfo(path).FullName;
     if (!path.StartsWith(templateBasePath))
     {
         throw new ArgumentException(string.Format(CultureInfo.CurrentCulture,Resources.TemplateNotFoundMessage));
     }
     templateCode = File.ReadAllText(path);
     this.Content = base.Render(templateCode, path);
 }
开发者ID:riseandcode,项目名称:open-wscf-2010,代码行数:28,代码来源:ExtendedTextTemplateAction.cs

示例8: CreateStore

        private void CreateStore()
        {
            string template = @"Text\Store.js.t4";
            string templateBasePath = GetTemplateBasePath();
            if (!Path.IsPathRooted(template))
            {
                template = Path.Combine(templateBasePath, template);
            }
            template = new FileInfo(template).FullName;
            if (!template.StartsWith(templateBasePath))
            {
                throw new ArgumentException("Template Not found");
            }
            string templateCode = File.ReadAllText(template);

            var addProjectItemAction = new AddProjectItemAction();
            addProjectItemAction.Content = Render(templateCode, template).ToString();
            addProjectItemAction.IsValid = true;
            addProjectItemAction.TargetFileName = ModelClassName + "s.js";
            addProjectItemAction.Project = CurrentProject;
            addProjectItemAction.Execute(DteHelper.FindInCollection(CurrentProject.ProjectItems, TemplateConfiguration.GetConfiguration().ExtRootFolderName + "\\Store"));
        }
开发者ID:andyshao,项目名称:extjs-mvc-templates-for-visual-studio,代码行数:22,代码来源:GenerateModelClass.cs


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