Suggestions on what to do?

Hello everyone,

My disk space has been getting low recently and so I decided to write a program to list files/folders above 300 megs in a listbox. Unfortunately, I have no idea what kind of controls I'd want to use in C# and I don't want to use VB as I'm trying to learn C#, so this should be a good project.

Any ideas



Answer this question

Suggestions on what to do?

  • evilone

    I've been trying to figure out how to get an array of the directories, to no success.


           
            private void cmdStart_Click(object sender, EventArgs e)
            {
                Directory[] objArrDirs = Directory.GetDirectories("C:\\");
                foreach(Directory objDir in objArrDirs)
                {
                    MessageBox.Show(objDir);
                }
            }

     


    That is what I'm doing. It errors saying something about not being able to convert from string to static or something like that. Any ideas


  • Thomas Ott

    I'll take a look at that.

    About VB.NET. Never used it. I used VB6 =\. I'm thinking about getting .NET, but I'd really like to move on to more C-based languages. VB honestly isn't a great choice for the kind of things I want to program (games and cpu-eating applications).

    Thanks again for your help. More suggestions are openly welcomed =D

    EDIT: There seems to be no "Directory" under System.IO.

    Second Edit: I found it, I was trying to use Sytem.IO.Directory when I just needed to do System.IO. Sorry.


  • Bliszek

    There was a very slight difference occasionally with the MSIL created by vb.net and c# in 1.0/1.1 (see here for an example). THis was so small, as to be imperceptible. Both compilers were altered in 2.0, and the MSIL they create is now even closer.

    Cathal

  • DanielRehn

    I'm really sorry, but you're really confused.  The point of a compiler is to turn the text you type into an IDE into something the computer can understand.  The C++ compiler does this, but both C# and VB.NET instead turn it into code called MSIL, a language that the .NET framework can understand, and the .NET framework turns this into byte code that the computer can understand/run.  The text you type into the IDE means that VB.NET source files will be bigger, but the difference in MSIL will be significantly less, and won't have real speed implications at all.



  • kismath

    It would make no sense whatsoever if theyre the same speed simply because VB uses text syntax (IF/THEN) while C# uses single characters (if(){/}), there has to be a little tiny bit of difference, and even if there isn't, C# apps should be smaller for the same reason, which is also going to run faster.

    Not trying to prove you wrong, just explaining my logic.


  • Change2

    C# offers the same controls as VB.NET.  I'd imagine if you want to show a disk heirarchy, a tree view is the best choice.  System.IO.Directory has GetFolders and GetFiles methods to help you iterate through the files on disk.


  • Vishal Bansod

    Directory.GetDirectories returns a string array, not an array of Directory objects.  Directory is a static class, you are better off using the non-static DirectoryInfo

    DirectoryInfo rootDir = new DirectoryInfo("c:\\");

    DirectoryInfo[] subDirs = rootDir.GetDirectories();

    foreach(DirectoryInfo objDir in subDirs)

    {

    MessageBox.Show(objDir.FullName);

    }


  • Kylin.Sandfield

    I don't want to burst your bubble, but VB.NET and C# are the same, speed wise.  C# is a better language, but not for speed reasons.  C# has a C++ like syntax, but you need to actually use C++ if you want to write 'cpu eating applications'.  :-)

  • Suggestions on what to do?