Code Is Only Writing Last Data To Excel Repeatedly - c#

Instead of writing each element from my foreach loop, my syntax is only writing the last value of the foreach loop to every cell. I am sure this is something that I have overlooked, but what needs to be changed in my syntax so that it will write each element of the foreach loop accordingly on each line?
foreach (var calcs in dictionary)
{
var FileInfo = new FileInfo(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory), "WriteDataToExcelThroughCode.xlsx"));
using (ExcelPackage package = new ExcelPackage(FileInfo))
{
ExcelWorksheet ws = package.Workbook.Worksheets["TTest2"];
//ExcelWorksheet ws = package.Workbook.Worksheets[0];
ws.Cells["A24:C36"].Clear();
int z = 0;
int x = 24;
while (z <= numofrows)
{
ws.Cells["A" + x + ":A" + x].Value = calcs.Key;
ws.Cells["B" + x + ":B" + x].Value = dictionary[calcs.Key][0];
ws.Cells["C" + x + ":C" + x].Value = dictionary[calcs.Key][1];
//ws.Cells["D" + x + "D" + x].Value = dictionary[calcs.Key][2];
x = x + 1;
z = z + 1;
}
package.Save();
}
}
EDIT
To better illustrate what my intended results are, is as follows.
Hypothetical calcs contains the following info
James 1 2
Jose 3 4
Bob 5 6
I want the following info to be written to the following cells
A24 = James B24 = 1 C24 = 2
A25 = Jose B25 = 3 C25 = 4
A26 = Bob B26 = 5 C26 = 6
Edit 2
My variable numofrows is set-up like so
int start = Convert.ToInt32(txtstart.Text);
int end = Convert.ToInt32(txtEnd.Text) + 1;
int numofrows = end - start;
int[] abc = Enumerable.Range(start, end-start).ToArray();
foreach (int a in abc)
{
Dictionary<int, int[]> dictionary = new Dictionary<int, int[]>();
dictionary.Add(a, new int[] { 2, 3 });
foreach (var calcs in dictionary)
{
// original code
}
}
private void btnHitIT_Click(object sender, EventArgs e)
{
int start = Convert.ToInt32(Alpha);
int end = Convert.ToInt32(AlphaEnd)+1;
int numofrows = end - start;
int[] angles = Enumerable.Range(start, end - start).ToArray();
foreach (int a in angles)
{
Dictionary<int, int[]> dictionary = new Dictionary<int, int[]>();
dictionary.Add("Jack", new int[] { 2, 3 });
dictionary.Add("James", new int[] { 7, 11 });
dictionary.Add("Jason", new int[] { 14, 21 });
pDrawingArea.Invalidate();
var FileInfo = new FileInfo(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory), "WriteDataToExcelThroughCode.xlsx"));
using (ExcelPackage package = new ExcelPackage(FileInfo))
{
ExcelWorksheet ws = package.Workbook.Worksheets["TTest2"];
int x = 24;
foreach (var calcs in dictionary)
{
ws.Cells["A24:C36"].Clear();
for (int z = 0; z <= numofrows; ++z)
{
ws.Cells["A" + x + ":A" + x].Value = calcs.Key;
ws.Cells["B" + x + ":B" + x].Value = dictionary[calcs.Key][0];
ws.Cells["C" + x + ":C" + x].Value = dictionary[calcs.Key][1];
++x;
}
}
package.Save();
}
}

You are defining and incrementing the variable x at the wrong place. You need to define it outside the foreach loop and increment it outside your while loop (but inside the foreach loop).
I have changed your inside while loop to a more appropriate for loop.
Also move the WorkSheet definition outside the foreach loop, since there is no reason to constantly open and close the excel file.
I notice that you search twice for the value in Dictionary given that you already have that value in calcs.Value
var FileInfo = new FileInfo(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory), "WriteDataToExcelThroughCode.xlsx"));
using (ExcelPackage package = new ExcelPackage(FileInfo))
{
ExcelWorksheet ws = package.Workbook.Worksheets["TTest2"];
//ExcelWorksheet ws = package.Workbook.Worksheets[0];
int x = 24;
foreach (var calcs in dictionary)
{
ws.Cells["A24:C36"].Clear();
for (int z = 0; z <= numofrows; ++z)
{
ws.Cells["A" + x + ":A" + x].Value = calcs.Key;
ws.Cells["B" + x + ":B" + x].Value = calcs.Value[0];
ws.Cells["C" + x + ":C" + x].Value = calcs.Value[1];
//ws.Cells["D" + x + "D" + x].Value = calcs.Value[2];
++x;
}
package.Save();
}
}

Related

Merge row dynamically while export using epplus

I want to merge rows in my exported excel using epplus. This code below only works if I just have one same value in one column.
e.g (I merge same value in Col1 row) :
But, if I have another table like this, the code getting error while do merge (I merge same value in Col1 and Col2 row)
Pls, help me fix the code.
void mergeCells(DataTable dt, int startIndex, int totalColumns, ExcelWorksheet ws)
{
if (totalColumns == 0) return;
int i, count = 1;
ArrayList lst = new ArrayList();
lst.Add(ws.Cells[2, 1]);
var ctrl = ws.Cells[startIndex + 1, 1];
for (i = 1; i <= dt.Rows.Count; i++)
{
ExcelRange nextMerge = ws.Cells[i + totalColumns + 1, 1];
if (ctrl.Text == nextMerge.Text)
{
count++;
lst.Add(ws.Cells[i, 1]);
}
else
{
if (count > 1)
{
ws.Cells[i + 1, 1, i + count, 1].Merge = true;
mergeCells(new DataTable(lst.ToString()), startIndex + count, totalColumns, ws);
}
count = 1;
lst.Clear();
ctrl = ws.Cells[i + 2, startIndex];
lst.Add(ws.Cells[i, 1]);
}
}
if (count > 1)
{
ws.Cells[startIndex + 1, 1, startIndex + count, 1].Merge = true;
mergeCells(new DataTable(lst.ToString()), startIndex + count, totalColumns - 1, ws);
}
count = 1;
lst.Clear();
}
I have done like this:
public void WriteDataToSheet(DataTable data)
{
using (ExcelPackage excel = new ExcelPackage())
{
ExcelWorksheet ws = excel.Workbook.Worksheets.Add("Test");
ws.Cells["A1"].LoadFromDataTable(data, true);
ws.Cells[ws.Dimension.Address].AutoFitColumns();
var listObject = data.AsEnumerable()
.Select(x => new
{
Col1 = x.Field<string>("Col1"),
Col2 = x.Field<string>("Col2"),
Col3 = x.Field<string>("Col3")
}).ToList();
var lisa = listObject.GroupBy(x => x.Col1).
Select(x => new
{
Id = x.Key,
Quantity = x.Count(),
secondGroup = x.GroupBy(y => y.Col2)
.Select(y => new
{
ID = y.Key,
secondGroup = y.Count()
})
});
int A = 1, B = 0, C = 1, D = 0;
foreach (var item in lisa)
{
B = A + 1;
A += item.Quantity;
ws.Cells["A" + B + ":A" + A + ""].Merge = true;
ws.Cells["B" + B + ":B" + A + ""].Merge = true;
foreach (var item2 in item.secondGroup)
{
D = C + 1;
C += item2.secondGroup;
ws.Cells["C" + D + ":C" + C + ""].Merge = true;
}
}
// Save merged and modified file to the location
}
}

C# merge lines of strings into groups of 3 at a time

I have a string like this (including newlines)
A2,
10.22,
-57,
A,
10.23,
-68,
A2,
10.24,
-60,
LB,
10.25,
-62,
I am trying to make this string to look like this:
A2,10.22,-57,
A,10.23,-68,
A2,10.24,-60,
LB,10.25,-62,
I need to join string in every 3 line i have tried :
int numLines = a.Split('\n').Length;
for (int i = 0; i < numLines; i += 3)
{
richTextBox1.Text = a.Replace("\n", "");
}
But it is not working for me. Please help me out
You can also approach this with LINQ, by using the index overload of .Select to retain a running count of the line numbers, and then to group them into groups of 3 - I've used integer division to Floor the line index, 3 at a time, but there are likely other suitable ways.
var groups = values.Select((s, idx) => (Index: idx / 3, Value: s))
.GroupBy(x => x.Index);
Where each item in the groups above will be IEnumerable<(Index, Value)>.
You'll also need to be wary of newlines - these may be \r\n in Windows, not just the \n you've indicated.
Here's an example:
var a =
#"A2,
10.22,
-57,
A,
10.23,
-68,
A2,
10.24,
-60,
LB,
10.25,
-62,";
var values = a.Split(new[] { "\r\n", "\r", "\n" }, StringSplitOptions.None);
var groups = values.Select((s, idx) => (Index: idx / 3, Value: s))
.GroupBy(x => x.Index);
foreach (var grp in groups)
{
Console.WriteLine(string.Join("", grp.Select(x => x.Value)));
}
Since you've already got commas at the end of each string (including the last one), there's no need to add another separator.
Output:
A2,10.22,-57,
A,10.23,-68,
A2,10.24,-60,
LB,10.25,-62,
Why not use the array that the split gives you instead?
var newArr = a.Split('\n');
for (int i = 0; i < newArr.Length; i += 3)
{
richTextBox1.Text = newArr[i] + newArr[i + 1] + newArr[i + 2];
}
Just don't forget to check the length of the arrays so that you don't get a IndexOutOfRange Exception.
I'm assuming that the input is actually coming from a file here.
var file = //file path
var sb = new StringBuilder();
var lineNum = 1;
var output = string.Empty;
using (var reader = new StreamReader(file))
{
while (!reader.EndOfStream)
{
var line = reader.ReadLine();
if (lineNum % 3 == 0)
{
output += sb.ToString() + "\n";
sb.Clear();
}
else
sb.Append(line);
lineNum++;
}
}
richTextBox1.Text = output;
Try this solution which is a combination of linq and for loop
var result = "";
var items = yourInputString.Split('\n');
for(var i=0; i<items.Count();i=i+3)
{
result += string.Join(",",items.Skip(i).Take(3))+"\n";
}
static void Main(string[] args)
{
var Lines = System.IO.File.ReadAllLines("input.txt");
var Result = new StringBuilder();
var SB = new StringBuilder();
for (var i = 0; i < Lines.Length; i++)
{
SB.Append(Lines[i]);
if ((i+1) % 3 == 0)
{
Result.Append($"{SB.ToString()}{Environment.NewLine}");
SB.Clear();
}
}
System.IO.File.WriteAllText("output.txt", Result.ToString());
}
Try to use Aggregate function
var outPutList = data.Replace("\r", string.Empty).Replace("\n", string.Empty).Split(",").Aggregate(new StringBuilder(""), (x, y) =>
{
if (double.TryParse(y, out double parsedValue))
x.Append(" " + parsedValue);
else
{
x.Append(Environment.NewLine);
x.Append(y.Trim());
}
return x;
});
richTextBox1.Text = outPutList.ToString();
Here is the output
try this works
private void button1_Click(object sender, EventArgs e)
{
//put your string in a textxbox with multiline property set to true
string[] s = textBox1.Text.Replace("\r", "").Replace("\n", "").Split(',');
string r = "";
for (int i = 0; i < s.Length; i++)
{
r = r + s[i] + ",";
if ((i + 1) % 3 == 0)
r = r + "+";
}
if (r.Substring(r.Length - 1, 1) == ",")
r = r.Substring(0, r.Length - 1);
if (r.Substring(r.Length - 1, 1) == "+")
r = r.Substring(0, r.Length - 1);
string[] finalArrayString = r.Trim().Split('+');
//just for show the result
textBox1.Text = "";
for (int i = 0; i < finalArrayString.Length; i++)
textBox1.Text = textBox1.Text + finalArrayString[i] + "\r\n";
}
hope it helps you

Formula not identify cell values

I'm generating an excel using the following code in my ASP.Net MVC Application
var fileName = DateTime.Now.ToString("yyyy-MM-dd--hh-mm-ss") + ".xlsx";
var outputDir = ConfigurationManager.AppSettings["ExcelUploadPath"];
// var fileName = "ExcellData.xlsx";
var file = new FileInfo(outputDir + fileName);
var fDate = JsonConvert.DeserializeObject<DateTime>(fromDate);
var tDate = JsonConvert.DeserializeObject<DateTime>(toDate);
using (var package = new OfficeOpenXml.ExcelPackage(file))
{
// add a new worksheet to the empty workbook
ExcelWorksheet worksheet = package.Workbook.Worksheets.Add("Plan " + DateTime.Now.ToShortDateString());
// --------- Data and styling goes here -------------- //
DataTable dt = planService.GetFlow(fDate, tDate, customerId, ordertypeId, suppliers, items);
if (dt != null)
{
int iCol = 1;
// Add column headings...
for (int i = 9; i < dt.Columns.Count; i++)
{
dt.Columns[i].ColumnName = dt.Columns[i].ColumnName.MultiInsert("/", 1, 3);
}
foreach (DataColumn c in dt.Columns)
{
worksheet.Cells[1, iCol].Value = c.ColumnName;
worksheet.Cells[1, iCol].Style.Fill.PatternType = ExcelFillStyle.Solid;
worksheet.Cells[1, iCol].Style.Font.Bold = true;
worksheet.Cells[1, iCol].Style.Fill.BackgroundColor.SetColor(Color.LightGray);
iCol++;
}
for (int j = 0; j < dt.Rows.Count; j++)
{
for (int k = 0; k < dt.Columns.Count; k++)
{
worksheet.Cells[j + 2, k + 1].Value = dt.Rows[j].ItemArray[k].ToString();
if (int.Parse(dt.Rows[j].ItemArray[7].ToString()) == 6)
{
worksheet.Cells[j + 2, k + 1].Style.Locked = false;
worksheet.Cells[j + 2, k + 1].Style.Fill.PatternType = ExcelFillStyle.Solid;
worksheet.Cells[j + 2, k + 1].Style.Fill.BackgroundColor.SetColor(Color.Cyan);
}
if (int.Parse(dt.Rows[j].ItemArray[7].ToString()) == 7)
{
worksheet.Cells[j + 2, k + 1].Style.Locked = false;
worksheet.Cells[j + 2, k + 1].Style.Fill.PatternType = ExcelFillStyle.Solid;
worksheet.Cells[j + 2, k + 1].Style.Fill.BackgroundColor.SetColor(Color.Magenta);
//worksheet.Cells[j + 2, k + 1].Formula =
if((k+1) > 10){
var addressList = new List<string>();
for (int i = 11; i <= k+1; i++)
{
addressList.Add(worksheet.Cells[((j + 2) -1) , i].Address);
}
var lstAdress = String.Join(",", addressList);
worksheet.Cells[j + 2, k + 1].Formula = "SUM(" + lstAdress + ")";
}
}
if (int.Parse(dt.Rows[j].ItemArray[7].ToString()) == 8)
{
//worksheet.Cells[j + 2, k + 1].Style.Locked = false;
worksheet.Cells[j + 2, k + 1].Style.Fill.PatternType = ExcelFillStyle.Solid;
worksheet.Cells[j + 2, k + 1].Style.Fill.BackgroundColor.SetColor(Color.Gray);
}
}
var colCount = dt.Columns.Count;
// worksheet.Cells[j+2, 8, j+2, colCount- 1].Style.Numberformat.Format = "0.000";
var range = worksheet.Cells[j + 2, 9, j + 2, colCount - 1];
var r = range.ToString();
var decimalValidation = worksheet.DataValidations.AddDecimalValidation(range.ToString());
decimalValidation.ShowErrorMessage = true;
decimalValidation.ErrorStyle = ExcelDataValidationWarningStyle.stop;
decimalValidation.ErrorTitle = "The value you entered is not valid";
decimalValidation.Error = "This cell must be a valid positive number.";
decimalValidation.Operator = ExcelDataValidationOperator.greaterThanOrEqual;
decimalValidation.Formula.Value = 0D;
}
worksheet.Cells[worksheet.Dimension.Address].AutoFitColumns();
worksheet.Column(1).Hidden = true;
worksheet.Column(2).Hidden = true;
worksheet.Column(3).Hidden = true;
worksheet.Column(4).Hidden = true;
worksheet.Column(5).Hidden = true;
worksheet.Column(8).Hidden = true;
worksheet.Column(9).Hidden = true;
worksheet.Column(10).Hidden = true;
worksheet.Protection.IsProtected = true;
// save our new workbook and we are done!
worksheet.Calculate();
package.Save();
return Json(fileName, JsonRequestBehavior.AllowGet);
}
else
{
return Json("NoData", JsonRequestBehavior.AllowGet);
}
}
return Json("", JsonRequestBehavior.AllowGet);
Here I'm setting my formula with comma separated cell names eg:
SUM(A1,A2,A3.. etc)
The excel file is generating correctly. But the problem is the formula calculation is not happen when I open my excel file.
The formula works when I manually change a cell value in Column Type Agreed Flow.
And it can only identify values of manually edited cells.
How can I resolve this?
Formula recalculation is both an Excel and a workbook setting.
You could set it with at the workbook level with
workbook.CalcMode = ExcelCalcMode.Automatic;
If the user has set it to manual though, the formulas won't be recalculated.
If you want to ensure the saved values are correct you can force the calculation by calling
worksheet.Calculate();
You can also calculate the formulas at the workbook or range level, eg :
worksheet.Cells[j + 2, k + 1].Calculate();
or
package.Workbook.Calculate();
This is explained in the documentation. Keep in mind that EPPlus doesn't contain Excel's formula engine. It uses its own engine to parse and calculate formulas. Some things aren't supported
It worked when I change my formula as follows..
var addressList = new List<string>();
for (int i = 11; i <= k+1; i++)
{
addressList.Add(worksheet.Cells[((j + 2) -1) , i].Address);
}
var lstAdress = String.Join("+", addressList);
worksheet.Cells[j + 2, k + 1].Formula = "(" + lstAdress + ")";
I think there is an issue in my excel sheet when I use the SUM function So I write the formula without using it. Then it worked
(A1+B1+C1+D1+ ..... etc)

Count Pattern / String Occurrence Per Group using C# in ASP.Net

This is the sample textfile
Line is categorized by date, per line date can be repeated like for example, December 1 and 2 have two entries. Expected Output should be counting the pattern "D;" for example per date
2016-12-01 - 7
2016-12-02 - 9
2016-12-03 - 5
This is what I currently have
using (StreamReader stRead = new StreamReader(FileUpload1.PostedFile.InputStream))
{
while (!stRead.EndOfStream)
{
var readedLine = stRead.ReadLine();
if (!string.IsNullOrWhiteSpace(readedLine))
{
for (int j = 01; j <= 31; j++)
{
int readedLineTime = Convert.ToInt32(readedLine.Substring(09, 02));
if (readedLineTime == j)
{
MatchCollection collection = Regex.Matches(readedLine, #"D;");
countedChars = collection.Count;
textfileOutput += readedLine.Substring(0, 11) + " - " + countedChars + Environment.NewLine;
}
}
}
textfileContent += readedLine + Environment.NewLine;
i++;
}
TextBox1.Text = textfileOutput;
TextBox2.Text = textfileContent;
Label1.Text = i.ToString();
//Label1.Text = this.TextBox1.Text.Split(new Char[] { '\n' }, StringSplitOptions.RemoveEmptyEntries).Length.ToString();
// Label2.Text = filename;
}
and this is its current output that is being displayed in multiple line textbox
2016-12-01 - 4
2016-12-01 - 3
2016-12-02 - 4
2016-12-02 - 5
2016-12-03 - 5
Let me know if this works.
Dictionary<string, int> dMyobject = new Dictionary<string, int>();
while (!stRead.EndOfStream)
{
var readedLine = stRead.ReadLine();
if (!string.IsNullOrWhiteSpace(readedLine))
{
int readedLineTime = Convert.ToInt32(readedLine.Substring(09, 02));
string sDate = readedLine.Substring(0, 11);
MatchCollection collection = Regex.Matches(readedLine, #"D;");
countedChars = collection.Count;
if (!dMyobject.Keys.Contains(sDate))
{
dMyobject.Add(sDate, collection.Count);
}
else
{
dMyobject[sDate] = dMyobject[sDate] + collection.Count;
}
}
textfileContent += readedLine + Environment.NewLine;
i++;
}
You will need to push these values in some collection. So that you can check it.
Later, for using these values for printing or anything, use following
foreach (var item in dMyobject)
{
Console.WriteLine(item.Key + " " + item.Value);
}
string line = "";
Dictionary<string, int> list = new Dictionary<string, int>();
int count;
if (File.Exists(fileName) == true)
{
StreamReader objReader;
objReader = new StreamReader(fileName);
StreamWriter file = new StreamWriter(OutputfileName");
do
{
line = objReader.ReadLine();
string temp = line.Substring(0, 10);
if (!list.ContainsKey(temp))
{
MatchCollection collection = Regex.Matches(line, #"D;");
count = collection.Count;
list.Add(temp, count);
}
else
{
MatchCollection collection = Regex.Matches(line, #"D;");
count = collection.Count;
var val = list[temp];
list[temp] = count + val;
}
} while (objReader.Peek() != -1);
foreach (var j in list)
{
file.WriteLine(j.Key + " - " + j.Value+"\n");
}
file.Close();
}

Using bubble-sort to sort a text file by rows

I am creating text file with 50 rows, each row have information about files. Words in row are separated by ';'. I need to sort files with bubble-sort algorithm by file size, it is third word, and write rows from file sorted in console. That means first row will have biggest file size, second, third, etc...
So far I have this:
Random rnd = new Random();
if (!File.Exists(#"C:\Users\ariak_000\Desktop\Řadící algoritmy\database\alpha.txt")) //C:\Users\bartbo13it\Downloads\alpha.txt
{
string[] arrayx = new string[50];
string[] arrayy = arrayx.Select(ggg => String.Join(";", new string[] { #"C:\user\directory", "file" + rnd.Next(100, 999), rnd.Next(0, 999999).ToString(), "txt", rnd.Next(0, 1).ToString() })).ToArray();
File.WriteAllLines(#"C:\Users\ariak_000\Desktop\Řadící algoritmy\database\alpha.txtt", arrayy);
}
string[] lines = System.IO.File.ReadAllLines(#"C:\Users\ariak_000\Desktop\Řadící algoritmy\database\alpha.txt");
int pocet_radku = File.ReadAllLines(#"C:\Users\ariak_000\Desktop\Řadící algoritmy\database\alpha.txt").Length;
List<int> velikostsouboru = new List<int>();
using (StreamReader sr = new StreamReader(#"C:\Users\ariak_000\Desktop\Řadící algoritmy\database\alpha.txt"))
{
Console.WriteLine("Pocet radku " + pocet_radku);
for (int i = 0; i < pocet_radku; i++)
{
string radek = sr.ReadLine();
string[] rozdeleni = radek.Split(';');
int ParsePokus = Int32.Parse(rozdeleni[2]);
velikostsouboru.Add(ParsePokus);
}
}
int[] array = velikostsouboru.ToArray();
for (int i = 0; i < array.Length - 1; i++)
{
for (int j = 0; j < array.Length - i - 1; j++)
{
if (array[j + 1] > array[j])
{
int temp = array[j];
array[j] = array[j + 1];
array[j + 1] = temp;
}
}
}
for (int a = 0; a < array.Length; a++)
{
Console.WriteLine(array[a] + " ");
}
Console.ReadKey();
It just sorts file size with bubble-sort algorithm and writes file sizes in console sorted from biggest to smallest. Still need to write whole lines sorted, not just file size.
I will appreciate any help.
// There are better ways to create a file, but I decided to keep it in the original.
const string filePath = #"C:\Users\ariak_000\Desktop\Řadící algoritmy\database\alpha.txt";
var rnd = new Random();
if (!File.Exists(filePath))
{
var array = new string[50].Select(x => String.Join(";", new[]
{
#"C:\user\directory",
"file" + rnd.Next(100, 999),
rnd.Next(0, 999999).ToString(CultureInfo.InvariantCulture),
"txt",
rnd.Next(0, 1).ToString(CultureInfo.InvariantCulture)
})).ToArray();
File.WriteAllLines(filePath, array);
}
// It will read the file and fill a variable with the data
// Convert the value to int is necessary in the order process
// Otherside, it will consider 9 higher than 10.
var data = File.ReadAllLines(filePath)
.Select(value => value.Split(';'))
.Select(x => new
{
Folder = x[0],
FileName = x[1],
Size = Convert.ToInt32(x[2]),
Extension = x[3],
IsActive = x[4]
})
.ToList<dynamic>();
// You can change it using the bubble sort as you wish
// I preffer the linq way.
var orderedData = data.OrderByDescending(x => x.Size);
// Writes the header in console (du~)
Console.WriteLine("Folder" + "\t\t\t"
+ "FileName" + "\t"
+ "Size" + "\t"
+ "Extension" + "\t"
+ "IsActive");
foreach (var result in orderedData)
{
// If you want to write the result in a file, you do it here.
Console.WriteLine(result.Folder + "\t"
+ result.FileName + "\t\t"
+ result.Size + "\t"
+ result.Extension + "\t\t"
+ result.IsActive);
}
Console.ReadKey();

Categories

Resources