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


C# FileInfo.Contains方法代码示例

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


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

示例1: PullAtLogin

        public static void PullAtLogin(string username, string accesstoken, StreamWriter sw, StreamReader sr)
        {
            /**
             * In questa funzione non abbiamo bisogno di inibire il FSWatcher per i file appena pullato perchè il FSWatcher non è ancora partito.
             * */
            bool nuovo = false;

            /** Scarico la lista di tutti i file del vfs del server **/
            PullListResponse pl= DoPullList(username,accesstoken,-1,SyncToken.Instance.VFSVersion,sw,sr);
            IEnumerable<string> dirtree = pl.DirTree;
            IEnumerable<VFile> listServer = pl.List; //in listServer ho la lista di tutti i file del file system del server
            try
            {
                FSWatcher.Instance.SetIgnoreDirs(dirtree);
                // Allinea la struttura delle directories
                DownloadRemoteDirTree(dirtree, sw, sr);
            }
            finally {
                FSWatcher.Instance.ClearIgnoreDirs();
            }

            /** tutti i file che NON sono nel dizionario li devo pushare **/
            Dictionary<string, VFile> processedFile = new Dictionary<string, VFile>();

            string rootPath = GetRootPath();
            /** Per ogni file sul server, devo fare le diverse prove **/
            foreach (VFile vf in listServer)
            {
                string absolutePath = new FileInfo(Path.Combine(rootPath, "." + vf.Path, vf.Name)).FullName;
                /** se il file sul vfs del client esiste **/
                if (File.Exists(absolutePath))
                {
                    /** e il file sul server era eliminato **/
                    if (vf.Deleted)
                    {
                        if (vf.Hash == GetFileHash(absolutePath))
                        {
                            File.Delete(absolutePath);
                        }
                        else
                        {
                            /** rinominare il file perché è un conflitto **/
                            string str = null;
                            string conflictAppendix = "_conflicted_at_" + DateTime.Now.Ticks;
                            if (absolutePath.Contains('.'))
                                str = absolutePath.Insert(absolutePath.LastIndexOf('.'), conflictAppendix);
                            else
                                str = absolutePath + conflictAppendix;
                            File.Move(absolutePath, str);
                            /** Non devo aggiungere nulla al dizionario **/
                        }
                    }
                    /** Il file sul server esiste ancora **/
                    else
                    {
                        /** e l'hash del file è uguale **/
                        if (vf.Hash == GetFileHash(absolutePath))
                        {
                            /** File sincronizzato, non devo fare nuall **/
                            /** Aggiungere il file all'interno del dizionario **/
                            processedFile.Add(absolutePath, vf);
                        }
                        else
                        {
                            /** copia di conflitto -- rinominare **/
                            string str = null;
                            string conflictAppendix = "_conflicted_at_" + DateTime.Now.Ticks;
                            if (absolutePath.Contains('.'))
                                str = absolutePath.Insert(absolutePath.LastIndexOf('.'), conflictAppendix);
                            else
                                str = absolutePath + conflictAppendix;
                            File.Move(absolutePath, str);

                            // Ora devo pullare il nuovo file.
                            try
                            {
                                /** Devo pullare il file **/
                                var fileResponse = UserUtils.DoDownloadFile(vf.Id, vf.Version, SyncToken.Instance.VFSVersion, username, accesstoken, true, sw, sr);
                                var upChunk = fileResponse.List;
                                nuovo = !File.Exists(absolutePath);
                                HandleTempDownload(absolutePath, upChunk, username, accesstoken, sw, sr);
                            }
                            catch (Exception e)
                            {
                                if (File.Exists(absolutePath) && nuovo)
                                    File.Delete(absolutePath);
                                throw e;
                            }
                            processedFile.Add(absolutePath, vf);
                        }
                    }
                }
                else
                {
                    if (!vf.Deleted)
                    {
                        try
                        {
                            /** Devo pullare il file **/
                            var fileResponse = UserUtils.DoDownloadFile(vf.Id, vf.Version, SyncToken.Instance.VFSVersion, username, accesstoken, true, sw, sr);
//.........这里部分代码省略.........
开发者ID:albertogeniola,项目名称:MalnatiServer,代码行数:101,代码来源:UserUtils.cs

示例2: CreateHtmlReport


//.........这里部分代码省略.........
                                            <td width='5%' style='font-weight: " + Utility.GetParameter("ReportFontWeight") + @"; font-size: " + Utility.GetParameter("ReportFontSize") + @"; font-style:" + Utility.GetParameter("ReportFontStyle") + @"; color: " + Utility.GetParameter("ReportFontColor") + @"'>&nbsp;</td>
                                            <td width='10%' style='font-weight: " + Utility.GetParameter("ReportFontWeight") + @"; font-size: " + Utility.GetParameter("ReportFontSize") + @"; font-style:" + Utility.GetParameter("ReportFontStyle") + @"; color: " + Utility.GetParameter("ReportFontColor") + @"'>&nbsp;</td>
                                            <td width='15%' style='font-weight: " + Utility.GetParameter("ReportFontWeight") + @"; font-size: " + Utility.GetParameter("ReportFontSize") + @"; font-style:" + Utility.GetParameter("ReportFontStyle") + @"; color: " + Utility.GetParameter("ReportFontColor") + @"'>$TC_ExecutionTime_Date</td>
                                            <td width='25%' style='font-weight: " + Utility.GetParameter("ReportRemarksFontWeight") + @"; font-size: " + Utility.GetParameter("ReportFontSize") + @"; font-style:" + Utility.GetParameter("ReportRemarksFontStyle") + @"; color: " + Utility.GetParameter("ReportRemarksFontColor") + @"'>$TC_Remarks</td>
                                        </tr>
                                     </table>";
                string newTestCaseBodyEnd = @"</div>";

                string htmlEnd = @"</td>
                                 </tr>
                                  </table>
                                            </body>
                                </html>";

                //

                // Html Start
                finalHtml.Append(htmlStart);

                int count = 0;

                foreach (string xmlLocation in xmlFilesLocation)
                {
                    //using (StreamWriter sw = new StreamWriter(Property.ErrorLog))
                    //{
                    //    sw.WriteLine("Logfile Foreach 1");
                    //}
                    if (File.Exists(xmlLocation))
                    {
                        string rootFolderName = new FileInfo(xmlLocation).Directory.Parent.Name;
                        string rootFolderExt = string.Empty;
                        try
                        {
                            if (rootFolderName.Contains('-'))
                            rootFolderExt = rootFolderName.Substring(rootFolderName.IndexOf('-'),
                                                                            rootFolderName.Length -
                                                                            rootFolderName.IndexOf('-'));
                        }
                        catch
                        {
                            // ignored
                        }
                        Property.TotalCaseExecuted++;

                        try
                        {
                            #region Individual TestCase

                            var dsStore = new DataSet();
                            // copying all data from XML to datatable
                            dsStore.ReadXml(xmlLocation);

                            var dtTemp = dsStore.Tables[0];

                            // getting TestCase Name and ID from extended properties
                            if (dtTemp.ExtendedProperties["TestCase Name"] != null)
                                tcName = dtTemp.ExtendedProperties["TestCase Name"].ToString();
                            if (dtTemp.ExtendedProperties["TestCase Id"] != null)
                                tcId = dtTemp.ExtendedProperties["TestCase Id"].ToString();
                            if (dtTemp.ExtendedProperties["Browser"] != null)
                                tcBrowser = dtTemp.ExtendedProperties["Browser"].ToString();
                            if (dtTemp.ExtendedProperties["RCMachineId"] != null)
                                tcMachine = dtTemp.ExtendedProperties["RCMachineId"].ToString();
                            if ((dtTemp.ExtendedProperties["SauceJobUrl"] != null) && (dtTemp.ExtendedProperties["SauceJobUrl"].ToString() != ""))
                                tcJobResultLocation = dtTemp.ExtendedProperties["SauceJobUrl"].ToString();
开发者ID:Thinksys,项目名称:krypton,代码行数:66,代码来源:LogFile.cs


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