Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / NewStats: 3,195,076 members, 7,957,010 topics. Date: Tuesday, 24 September 2024 at 03:57 AM |
Nairaland Forum / Science/Technology / Programming / C Sharp Questions? Which Guru Can Write This Program??? (1674 Views)
What Do You Think Of This Program I Wrote / Capture Image From Webcam And Store In Mysql Database From C Sharp Winform / Java Vs C Sharp (2) (3) (4)
C Sharp Questions? Which Guru Can Write This Program??? by maninmood(m): 7:34pm On Jan 03, 2013 |
1. Full File Listing 2. Filtered File Listing 3. Folder Statistics: Display the following statistics about all the files in the current folder. Do not list any files in this case. Files in: C:\Windows Total files: 49 Total size of all files: 7121424 bytes Largest file: explorer.exe, 2871808 bytes Average file length: 145335 bytes 4. Quit, to exit the program After each operation (except 4) is complete wait for the user to press a key to continue, displaying an appropriate message to this effect. After the key press, the program should clear the screen, then return to the welcome message and the user may select another operation. |
Re: C Sharp Questions? Which Guru Can Write This Program??? by maninmood(m): 7:37pm On Jan 03, 2013 |
This is mine though, still struggling 'tryparsing' the int from Console.ReadLine(); using System; using System.Collections.Generic; using System.Linq; using System.IO; //This is added as we were asked to include it on this project using System.Text; namespace IntroProgAssignment { class Program { static void Main() { Console.WriteLine(" You are welcome, these are the lists of menu:" string[] menuLists = new string[4] { "List All Files", " List Filtered Files", "Display Statistics", "Quit"}; for (int ind = 0; ind < menuLists.Length; ind++) { Console.WriteLine(" {0}. {1}", ind + 1, menuLists[ind]); } Console.WriteLine(); Console.Write(" Enter the number you are accessing:" string userEntry = Console.ReadLine(); int userInput; bool isUserInput = int.TryParse(userEntry, out userInput); switch (userInput) { case 1: FullFileListing(); QuitProgram(); Main(); break; case 2: FilteredFileListing(); QuitProgram(); Main(); break; case 3: FolderStatistics(); QuitProgram(); Main(); break; case 4: QuitProgram(); Main(); // calling main function break; default: { while (isUserInput == false) { Console.WriteLine(" Sorry you need to enter from number 1 to 4" userEntry = Console.ReadLine(); isUserInput = int.TryParse(userEntry, out userInput); } } break; } Console.ReadLine(); } static void FullFileListing() { DirectoryInfo folderInfo = new DirectoryInfo("C:\\Windows" FileInfo[] files = folderInfo.GetFiles(); for (int index = 0; index < files.Length; index++) { Console.WriteLine("{0}. {1} ({2})", index + 1, files[index].Name, files[index].Length); } Console.WriteLine(); } static void FilteredFileListing() { DirectoryInfo folderInfo = new DirectoryInfo("C:\\Windows" Console.WriteLine(" Below are 'exe' files:" FileInfo[] exeFiles = folderInfo.GetFiles( "*.exe" for (int i = 0; i < exeFiles.Length; i++) { Console.WriteLine( "{0}. {1} ({2})", i + 1, exeFiles[i].Name, exeFiles[i].Length); } Console.WriteLine(" Below are 'dll' files:" FileInfo[] dllFiles = folderInfo.GetFiles("*.dll" for (int i = 0; i < dllFiles.Length; i++) { Console.WriteLine("{0}. {1} ({2})", i + 1, dllFiles[i].Name, dllFiles[i].Length); } Console.WriteLine(" Below are 'log' files:" FileInfo[] logFiles = folderInfo.GetFiles("*.log" for (int i = 0; i < logFiles.Length; i++) { Console.WriteLine("{0}. {1} ({2})", i + 1, logFiles[i].Name, logFiles[i].Length); } Console.WriteLine(" Below are 'ini' files:" FileInfo[] iniFiles = folderInfo.GetFiles("*.ini" for (int i = 0; i < iniFiles.Length; i++) { Console.WriteLine("{0}. {1} ({2})", i + 1, iniFiles[i].Name, iniFiles[i].Length); } Console.WriteLine(" Below are 'xml' files:" FileInfo[] xmlFiles = folderInfo.GetFiles("*.xml" for (int i = 0; i < xmlFiles.Length; i++) { Console.WriteLine("{0}. {1} ({2})", i + 1, xmlFiles[i].Name, xmlFiles[i].Length); } Console.WriteLine(" Below are 'prx' files:" FileInfo[] prxFiles = folderInfo.GetFiles("*.prx" for (int i = 0; i < prxFiles.Length; i++) { Console.WriteLine("{0}. {1} ({2})", i + 1, prxFiles[i].Name, prxFiles[i].Length); } Console.WriteLine(" Below are 'manifest' files:" FileInfo[] manifestFiles = folderInfo.GetFiles("*.manifest" for (int i = 0; i < manifestFiles.Length; i++) { Console.WriteLine("{0}. {1} ({2})", i + 1, manifestFiles[i].Name, manifestFiles[i].Length); } Console.WriteLine(" Below are 'bin' files:" FileInfo[] binFiles = folderInfo.GetFiles("*.bin" for (int i = 0; i < binFiles.Length; i++) { Console.WriteLine("{0}. {1} ({2})", i + 1, binFiles[i].Name, binFiles[i].Length); } Console.ReadLine(); } static void FolderStatistics() { DirectoryInfo statisticsInfo= new DirectoryInfo(" C:\\Windows" FileInfo[] files = statisticsInfo.GetFiles(); Console.WriteLine(" Total files is {0}", files.Length); Console.ReadLine(); } static void QuitProgram() { Console.WriteLine("Press Y to exit" string userAnswer = Console.ReadLine().ToUpper(); Console.Clear(); } } } Any better suggestion? |
Re: C Sharp Questions? Which Guru Can Write This Program??? by maninmood(m): 12:56pm On Jan 04, 2013 |
Any contribution, pls? |
Re: C Sharp Questions? Which Guru Can Write This Program??? by DigitalSignal(m): 9:01am On Jan 15, 2013 |
@OP: Must it be a guru? |
Re: C Sharp Questions? Which Guru Can Write This Program??? by maninmood(m): 12:03am On Jan 20, 2013 |
DigitalSignal: @OP: I sorted it out myself. Thanks for your contribution though. |
(1) (Reply)
Where To Learn Software Development And Engineering In Abuja On Part Time / An Abuja Based Firm Is In Need Of A Developer / How Much Would You Charge To Create A Ride Sharing Application Like Uber
(Go Up)
Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health religion celebs tv-movies music-radio literature webmasters programming techmarket Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 24 |