Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Ok, I have taken a quick look at the article you referenced and here are some comments that may help out.</p> <p>First lets take a look at </p> <pre><code>private string GetFileSize(double byteCount) { string size = "0 Bytes"; if (byteCount &gt;= 1073741824.0) size = String.Format("{0:##.##}", byteCount / 1073741824.0) + " GB"; else if (byteCount &gt;= 1048576.0) //etc... return size; } </code></pre> <p>What this should look like is something more like this</p> <pre><code>private string GetFileSize(double byteCount) { string size = "0 Bytes"; if (byteCount &gt; = 1073741824.0) { size = String.Format("{0:##.##}", byteCount / 1073741824.0) + " GB"; } else if (byteCount &gt;= 1048576.0) { //do something else in here } return size; } </code></pre> <p>You do not have to use the braces in the if/else statement to deliniate your blocks of code to execute if it is only a single line, I have included here for clarity. The C# compiler will associate the next executable line of code after and if or else with that if or else unless you use the {} to indicate the block or end the if or else line itself with a ";"</p> <p>The next problem you are having, is with the textFile.Text reference in the foreach loop. This is most likely a Textbox control on the form in the example. The parameter that you are filling in there is a filter for the type of files you are searching for. So you most likely do not have a Textbox on your form that has the name textFile.</p> <p>Edit: There is no one line command to get a list of all files recursively in a directory structure built in to the .NET framework. So you have the method below to do that for you. The way you would use this to have a single list of all the paths would be as follows.</p> <pre><code>List&lt;FileInfo&gt; DirSearch(string sDir) { List&lt;FileInfo&gt; filesList = new List&lt;FileInfo&gt;(); try { foreach (string d in Directory.GetDirectories(sDir)) { foreach (string f in Directory.GetFiles(d, txtFile.Text)) { fileList.Add(new FileInfo(f)); } DirSearch(d); } } catch (System.Exception excpt) { Console.WriteLine(excpt.Message); } return fileList; } </code></pre> <p>Now you can print out the details of each of those files by something like this.</p> <pre><code>foreach (FileInfo fi in new DirSearch("c:\")) { console.Writeline(String.Format("Filename: {0} Size: {1}", fi.Name, fi.Length)); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload