How to use GetFilesOfGivenType method of Ocaramba.Helpers.FilesHelper class

Best Ocaramba code snippet using Ocaramba.Helpers.FilesHelper.GetFilesOfGivenType

FilesHelper.cs

Source:FilesHelper.cs Github

copy

Full Screen

...77 /// <returns>78 /// Collection of files79 /// </returns>80 /// <example>How to use it: <code>81 /// var files = GetFilesOfGivenType(folder, FileType.Txt);82 /// </code></example>83 public static ICollection<FileInfo> GetFilesOfGivenType(string folder, FileType type)84 {85 return GetFilesOfGivenType(folder, type, string.Empty);86 }87 /// <summary>88 /// Gets the files of given type, use postfixFilesName in search pattern.89 /// </summary>90 /// <param name="folder">The folder.</param>91 /// <param name="type">The type of files.</param>92 /// <param name="postfixFilesName">Postfix name of files for search pattern.</param>93 /// <returns>94 /// Collection of files95 /// </returns>96 /// <example>How to use it: <code>97 /// var files = GetFilesOfGivenType(folder, FileType.Txt, "live");98 /// </code></example>99 public static ICollection<FileInfo> GetFilesOfGivenType(string folder, FileType type, string postfixFilesName)100 {101 Logger.Debug("Get Files '{0}' from '{1}', postfixFilesName '{2}'", type, folder, postfixFilesName);102 ICollection<FileInfo> files =103 new DirectoryInfo(folder)104 .GetFiles("*" + postfixFilesName + ReturnFileExtension(type)).OrderBy(f => f.Name).ToList();105 return files;106 }107 /// <summary>108 /// Gets the files of given type from all sub folders.109 /// </summary>110 /// <param name="folder">The folder.</param>111 /// <param name="type">The type of files.</param>112 /// <returns>113 /// Collection of files114 /// </returns>115 /// <example>How to use it: <code>116 /// var files = GetFilesOfGivenTypeFromAllSubFolders(folder, FileType.Txt);117 /// </code></example>118 public static ICollection<FileInfo> GetFilesOfGivenTypeFromAllSubFolders(string folder, FileType type)119 {120 return GetFilesOfGivenTypeFromAllSubFolders(folder, type, string.Empty);121 }122 /// <summary>123 /// Gets the files of given type from all sub folders, use postfixFilesName in search pattern.124 /// </summary>125 /// <param name="folder">The folder.</param>126 /// <param name="type">The type of files.</param>127 /// <param name="postfixFilesName">Postfix name of files for search pattern.</param>128 /// <returns>129 /// Collection of files130 /// </returns>131 /// <example>How to use it: <code>132 /// var files = GetFilesOfGivenTypeFromAllSubFolders(folder, FileType.Txt, "live");133 /// </code></example>134 public static ICollection<FileInfo> GetFilesOfGivenTypeFromAllSubFolders(string folder, FileType type, string postfixFilesName)135 {136 Logger.Debug("Get Files '{0}' from '{1}', postfixFilesName '{2}'", type, folder, postfixFilesName);137 List<FileInfo> files =138 new DirectoryInfo(folder)139 .GetFiles("*" + postfixFilesName + ReturnFileExtension(type), SearchOption.AllDirectories).OrderBy(f => f.Name).ToList();140 return files;141 }142 /// <summary>143 /// Gets all files from folder, use postfixFilesName in search pattern.144 /// </summary>145 /// <param name="folder">The folder.</param>146 /// <param name="postfixFilesName">Postfix name of files for search pattern.</param>147 /// <returns>148 /// Collection of files149 /// </returns>150 /// <example>How to use it: <code>151 /// var files = GetAllFiles(folder, "live");152 /// </code></example>153 public static ICollection<FileInfo> GetAllFiles(string folder, string postfixFilesName)154 {155 Logger.Debug("Get all files from '{0}', postfixFilesName '{1}'", folder, postfixFilesName);156 ICollection<FileInfo> files =157 new DirectoryInfo(folder)158 .GetFiles("*" + postfixFilesName).OrderBy(f => f.Name).ToList();159 return files;160 }161 /// <summary>162 /// Gets all files from all sub folders, use postfixFilesName in search pattern.163 /// </summary>164 /// <param name="folder">The folder.</param>165 /// <param name="postfixFilesName">Postfix name of files for search pattern.</param>166 /// <returns>167 /// Collection of files168 /// </returns>169 /// <example>How to use it: <code>170 /// var files = GetAllFilesFromAllSubFolders(folder, "live");171 /// </code></example>172 public static ICollection<FileInfo> GetAllFilesFromAllSubFolders(string folder, string postfixFilesName)173 {174 Logger.Debug("Get all files from '{0}', postfixFilesName '{1}'", folder, postfixFilesName);175 ICollection<FileInfo> files =176 new DirectoryInfo(folder)177 .GetFiles("*" + postfixFilesName, SearchOption.AllDirectories).OrderBy(f => f.Name).ToList();178 return files;179 }180 /// <summary>181 /// Gets all files from all sub folders.182 /// </summary>183 /// <param name="folder">The folder.</param>184 /// <returns>185 /// Collection of files186 /// </returns>187 /// <example>How to use it: <code>188 /// var files = GetAllFilesFromAllSubFolders(folder);189 /// </code></example>190 public static ICollection<FileInfo> GetAllFilesFromAllSubFolders(string folder)191 {192 return GetAllFilesFromAllSubFolders(folder, string.Empty);193 }194 /// <summary>195 /// Gets all files from folder.196 /// </summary>197 /// <param name="folder">The folder.</param>198 /// <returns>199 /// Collection of files200 /// </returns>201 /// <example>How to use it: <code>202 /// var files = GetAllFiles(folder);203 /// </code></example>204 public static ICollection<FileInfo> GetAllFiles(string folder)205 {206 return GetAllFiles(folder, string.Empty);207 }208 /// <summary>209 /// Get file by its name in given folder210 /// </summary>211 /// <param name="folder">The folder</param>212 /// <param name="fileName">The file name</param>213 /// <returns>FileInfo of file</returns>214 public static FileInfo GetFileByName(string folder, string fileName)215 {216 Logger.Debug("Get File '{0}' from '{1}'", fileName, folder);217 FileInfo file =218 new DirectoryInfo(folder)219 .GetFiles(fileName).First();220 return file;221 }222 /// <summary>223 /// Counts the files of given type.224 /// </summary>225 /// <param name="folder">The folder.</param>226 /// <param name="type">The type.</param>227 /// <returns>228 /// Number of files in subfolder229 /// </returns>230 /// <example>How to use it: <code>231 /// var filesNumber = FilesHelper.CountFiles(this.DriverContext.DownloadFolder, FileType.Txt);232 /// </code></example>233 public static int CountFiles(string folder, FileType type)234 {235 Logger.Debug(CultureInfo.CurrentCulture, "Count {0} Files in '{1}'", type, folder);236 var fileNumber = GetFilesOfGivenType(folder, type).Count;237 Logger.Debug(CultureInfo.CurrentCulture, "Number of files in '{0}': {1}", folder, fileNumber);238 return fileNumber;239 }240 /// <summary>241 /// Counts the files.242 /// </summary>243 /// <param name="folder">The folder.</param>244 /// <returns>245 /// Number of files in subfolder246 /// </returns>247 /// <example>How to use it: <code>248 /// var filesNumber = FilesHelper.CountFiles(this.DriverContext.DownloadFolder);249 /// </code></example>250 public static int CountFiles(string folder)...

Full Screen

Full Screen

CompareFiles.cs

Source:CompareFiles.cs Github

copy

Full Screen

...68 /// </returns>69 private static IEnumerable<TestCaseData> FindFiles(FileType type)70 {71 Logger.Info("Get Files {0}:", type);72 var liveFiles = FilesHelper.GetFilesOfGivenType(ProjectBaseConfiguration.DownloadFolderPath, type, "live");73 if (liveFiles != null)74 {75 foreach (FileInfo liveFile in liveFiles)76 {77 Logger.Trace("liveFile: {0}", liveFile);78 var fileNameBranch = liveFile.Name.Replace("live", "branch");79 var testCaseName = liveFile.Name.Replace("_" + "live", string.Empty);80 TestCaseData data = new TestCaseData(liveFile.Name, fileNameBranch);81 data.SetName(Regex.Replace(testCaseName, @"[.]+|\s+", "_"));82 Logger.Trace("file Name Short: {0}", testCaseName);83 yield return data;84 }85 }86 }...

Full Screen

Full Screen

GetFilesOfGivenType

Using AI Code Generation

copy

Full Screen

1using Ocaramba;2using Ocaramba.Extensions;3using Ocaramba.Helpers;4using NUnit.Framework;5using System;6using System.Collections.Generic;7using System.IO;8using System.Linq;9using System.Text;10using System.Threading.Tasks;11using System.Windows.Forms;12{13 {14 public void GetFilesOfGivenTypeTest1()15 {16 var files = FilesHelper.GetFilesOfGivenType(Directory.GetCurrentDirectory(), "*.txt");17 Assert.AreEqual(1, files.Count);18 }19 }20}21using Ocaramba;22using Ocaramba.Extensions;23using Ocaramba.Helpers;24using NUnit.Framework;25using System;26using System.Collections.Generic;27using System.IO;28using System.Linq;29using System.Text;30using System.Threading.Tasks;31using System.Windows.Forms;32{33 {34 public void DeleteFileTest1()35 {36 var file = FilesHelper.GetFilesOfGivenType(Directory.GetCurrentDirectory(), "*.txt").FirstOrDefault();37 FilesHelper.DeleteFile(file);38 var files = FilesHelper.GetFilesOfGivenType(Directory.GetCurrentDirectory(), "*.txt");39 Assert.AreEqual(0, files.Count);40 }41 }42}43using Ocaramba;44using Ocaramba.Extensions;45using Ocaramba.Helpers;46using NUnit.Framework;47using System;48using System.Collections.Generic;49using System.IO;50using System.Linq;51using System.Text;52using System.Threading.Tasks;53using System.Windows.Forms;54{

Full Screen

Full Screen

GetFilesOfGivenType

Using AI Code Generation

copy

Full Screen

1using System;2using System.Collections.Generic;3using System.Linq;4using System.Text;5using System.Threading.Tasks;6using Ocaramba.Helpers;7{8 {9 static void Main(string[] args)10 {11 var folderPath = @"C:\Users\Public\Documents\Ocaramba\";12 var fileType = "txt";13 var files = FilesHelper.GetFilesOfGivenType(folderPath, fileType);14 foreach (var file in files)15 {16 Console.WriteLine(file);17 }18 }19 }20}

Full Screen

Full Screen

GetFilesOfGivenType

Using AI Code Generation

copy

Full Screen

1public void GetFilesOfGivenTypeTest()2{3 var testFilesPath = Path.Combine(TestContext.TestDeploymentDir, "TestFiles");4 var files = FilesHelper.GetFilesOfGivenType(testFilesPath, "*.txt");5 Assert.AreEqual(2, files.Count);6}7public void GetFilesOfGivenTypeTest()8{9 var testFilesPath = Path.Combine(TestContext.TestDeploymentDir, "TestFiles");10 var files = FilesHelper.GetFilesOfGivenType(testFilesPath, "*.txt");11 Assert.AreEqual(2, files.Count);12}13public void GetFilesOfGivenTypeTest()14{15 var testFilesPath = Path.Combine(TestContext.TestDeploymentDir, "TestFiles");16 var files = FilesHelper.GetFilesOfGivenType(testFilesPath, "*.txt");17 Assert.AreEqual(2, files.Count);18}19public void GetFilesOfGivenTypeTest()20{21 var testFilesPath = Path.Combine(TestContext.TestDeploymentDir, "TestFiles");22 var files = FilesHelper.GetFilesOfGivenType(testFilesPath, "*.txt");23 Assert.AreEqual(2, files.Count);24}25public void GetFilesOfGivenTypeTest()26{27 var testFilesPath = Path.Combine(TestContext.TestDeploymentDir, "TestFiles");28 var files = FilesHelper.GetFilesOfGivenType(testFilesPath, "*.txt");29 Assert.AreEqual(2, files.Count);30}31public void GetFilesOfGivenTypeTest()32{33 var testFilesPath = Path.Combine(TestContext.TestDeploymentDir, "TestFiles");

Full Screen

Full Screen

GetFilesOfGivenType

Using AI Code Generation

copy

Full Screen

1using System;2using System.Collections.Generic;3using System.Linq;4using System.Text;5using System.IO;6using Ocaramba.Helpers;7{8 {9 static void Main(string[] args)10 {11 List<string> files = FilesHelper.GetFilesOfGivenType(Directory.GetCurrentDirectory(), ".cs");12 foreach (string file in files)13 {14 Console.WriteLine(file);15 }16 Console.ReadLine();17 }18 }19}

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful