march 27 - files big idea: i will know how to create software that can open and save to files ...
TRANSCRIPT
![Page 1: March 27 - Files Big Idea: I will know how to create software that can open and save to files Minds On: Learn how to learn Action: File Review](https://reader035.vdocument.in/reader035/viewer/2022080914/56649f3f5503460f94c60250/html5/thumbnails/1.jpg)
March 27 - Files Big Idea: I will know how to create
software that can open and save to files Minds On: Learn how to learn Action: File Review Consolidation: Continue or move on?
![Page 2: March 27 - Files Big Idea: I will know how to create software that can open and save to files Minds On: Learn how to learn Action: File Review](https://reader035.vdocument.in/reader035/viewer/2022080914/56649f3f5503460f94c60250/html5/thumbnails/2.jpg)
Learn how to learn What strategies do you use to be
successful in school? How do you learn independently?
![Page 3: March 27 - Files Big Idea: I will know how to create software that can open and save to files Minds On: Learn how to learn Action: File Review](https://reader035.vdocument.in/reader035/viewer/2022080914/56649f3f5503460f94c60250/html5/thumbnails/3.jpg)
What strategies do you use to be successful in school?
Organization
In class/on time
Do your homework
Stay awake
Stay focused
Stay clean
![Page 4: March 27 - Files Big Idea: I will know how to create software that can open and save to files Minds On: Learn how to learn Action: File Review](https://reader035.vdocument.in/reader035/viewer/2022080914/56649f3f5503460f94c60250/html5/thumbnails/4.jpg)
How do you learn independently?
Research
Practice
Trial and error
Have initiative
Read a book
Youtube
Be responsibl
e
Time table plan
![Page 5: March 27 - Files Big Idea: I will know how to create software that can open and save to files Minds On: Learn how to learn Action: File Review](https://reader035.vdocument.in/reader035/viewer/2022080914/56649f3f5503460f94c60250/html5/thumbnails/5.jpg)
File Streams
D r e w 8 4 Cr Lf
T i a 9 2 Cr Lf
-1
![Page 6: March 27 - Files Big Idea: I will know how to create software that can open and save to files Minds On: Learn how to learn Action: File Review](https://reader035.vdocument.in/reader035/viewer/2022080914/56649f3f5503460f94c60250/html5/thumbnails/6.jpg)
//Example 3 System.IO.FileInfo textFile3 = new
System.IO.FileInfo("wonder.txt"); System.IO.StreamReader readFile; String lineOfText;
![Page 7: March 27 - Files Big Idea: I will know how to create software that can open and save to files Minds On: Learn how to learn Action: File Review](https://reader035.vdocument.in/reader035/viewer/2022080914/56649f3f5503460f94c60250/html5/thumbnails/7.jpg)
try { readFile = new
System.IO.StreamReader(textFile3.FullName); while ((lineOfText = readFile.ReadLine()) != null) { Console.WriteLine(lineOfText); } readFile.Close(); }
![Page 8: March 27 - Files Big Idea: I will know how to create software that can open and save to files Minds On: Learn how to learn Action: File Review](https://reader035.vdocument.in/reader035/viewer/2022080914/56649f3f5503460f94c60250/html5/thumbnails/8.jpg)
catch (Exception e) { Console.WriteLine("File does not exist
or could not be found."); Console.WriteLine(e.Message); }
![Page 9: March 27 - Files Big Idea: I will know how to create software that can open and save to files Minds On: Learn how to learn Action: File Review](https://reader035.vdocument.in/reader035/viewer/2022080914/56649f3f5503460f94c60250/html5/thumbnails/9.jpg)
YOUR TASK Create a console application called u3MMDDReadFileName
that reads and then displays the contents of a file containing instructions for this assignment. Use Notepad to create the file and be sure it is saved as a Text file (TXT). The application will need to include the correct path to the location. Bonus marks if you can figure out how to do it without a path!
AND ANOTHER TASK Create a program called u3MMDDReadNumbersName that
reads a text file that has a number on each line. As each line is read the number should be output and the number should be added to a variable called intTotal. Another variable intNumbOfItems is increased by one. Once the file is finished, then the average is calculated and displayed.
![Page 10: March 27 - Files Big Idea: I will know how to create software that can open and save to files Minds On: Learn how to learn Action: File Review](https://reader035.vdocument.in/reader035/viewer/2022080914/56649f3f5503460f94c60250/html5/thumbnails/10.jpg)
FileInfo dataFile = new FileInfo("scores.dat");
StreamReader readFile; String score; Double avgScore; Double totalScores = 0; Int32 numScores = 0;
![Page 11: March 27 - Files Big Idea: I will know how to create software that can open and save to files Minds On: Learn how to learn Action: File Review](https://reader035.vdocument.in/reader035/viewer/2022080914/56649f3f5503460f94c60250/html5/thumbnails/11.jpg)
try { readFile = new StreamReader(dataFile.FullName); while ((score = readFile.ReadLine()) != null) { numScores += 1; Console.WriteLine(score); totalScores += Double.Parse(score); } avgScore = totalScores / numScores; Console.WriteLine("Average = " + avgScore); readFile.Close(); }
![Page 12: March 27 - Files Big Idea: I will know how to create software that can open and save to files Minds On: Learn how to learn Action: File Review](https://reader035.vdocument.in/reader035/viewer/2022080914/56649f3f5503460f94c60250/html5/thumbnails/12.jpg)
catch(Exception ex){ Console.WriteLine("The following error
occurred: "); Console.WriteLine(ex.Message); }