3 4 private void saveButton_Click(object sender, RoutedEventArgs e) { saveText("jot.txt", jotTextBox.Text); }

Slides:



Advertisements
Similar presentations
Reading and Writing Text Files Svetlin Nakov Telerik Corporation
Advertisements

If Statements, Try Catch and Validation. The main statement used in C# for making decisions depending on different conditions is called the If statement.
Charles Petzold Application Lifecycle and State Management.
Software Engineering Implementation Lecture 3 ASPI8-4 Anders P. Ravn, Feb 2004.
Chapter 3 DATA: TYPES, CLASSES, AND OBJECTS. Chapter 3 Data Abstraction Abstract data types allow you to work with data without concern for how the data.
APIWP7.1WP8W8 System.Net.WebClient  System.Net.HttpWebRequest (async only) System.Net.Http.HttpClient (NuGet) Windows.Web.Syndication.SyndicationClient.
Handling errors Objects First with Java - A Practical Introduction using BlueJ, © David J. Barnes, Michael Kölling Main concepts to be covered.
Copyright © 2012 Pearson Education, Inc. Chapter 8 Exception Handling.
C# - Files and Streams Outline Files and Streams Classes File and Directory Creating a Sequential-Access File Reading Data from a Sequential-Access.
Chapter 9: Sequential Access Files and Printing
1 Reader-writer Problem w/ Additional Requirement I Reader-writer problem: Share a buffer which holds one item (an integer) A single reader and writer.
Handling errors Writing robust code. 16/12/2004Lecture 10: Handling Errors2 Main concepts to be covered Defensive programming. –Anticipating that things.
True/False. False True Subject May Go Here True / False ? Type correct answer here. Type incorrect answer here.
SELECTION CSC 171 FALL 2004 LECTURE 8. Sequences start end.
1 Chapter 5 Concurrency. 2 Concurrency 3 4 Mutual Exclusion: Hardware Support Test and Set Instruction boolean testset (int *i) { if (*i == 0) { *i.
30 April 2014 Building Apps for Windows Phone 8.1 Jump Start WinRT Apps & Silverlight.
Performance measurements for inter-process communication.
Crossword Puzzle Solver Michael Keefe. Solver structure.
Windows Programming Using C# Windows Services, Serialization, and Isolated Storage.
Computer and Programming File I/O File Input/Output Author: Chaiporn Jaikaeo, Jittat Fakcharoenphol Edited by Supaporn Erjongmanee Lecture 13.
Georgia Institute of Technology Speed part 3 Barb Ericson Georgia Institute of Technology May 2006.
Handling errors Exception handling and throwing Simple file processing.
CC1007NI: Further Programming Week 8-9 Dhruba Sen Module Leader (Islington College)
File Handling. Data Files Programs that can only get data from the user interface are limited. –data must be entered each time. –only small amounts of.
Georgia Institute of Technology Creating and Modifying Text part 4 Barb Ericson Georgia Institute of Technology Oct 2005.
Application Code PDP PEP public void borrowBook (User user, Book book, Context context) throws PolicyViolationException { Request request = new Request.
File I/O 11_file_processing.ppt
1 Κατανεμημένες Διαδικτυακές Εφαρμογές Πολυμέσων Γιάννης Πετράκης.
Lecture 16: Multithreaded Programming. public partial class Form1 : Form { Thread ct; Thread rt; public static int circle_sleep = 0; public static int.
Effective C# 50 Specific Ways to Improve Your C# Item 46~ /09/25 1.
Multi-Client/Server GUI Application. Overview As part of the TCP.
1 Recitation 8. 2 Outline Goals of this recitation: 1.Learn about loading files 2.Learn about command line arguments 3.Review of Exceptions.
CPSC1301 Computer Science 1 Chapter 12 Creating and Modifying Text part 4.
Tutorial 9: Sequential Access Files and Printing1 Tutorial 9 Sequential Access Files and Printing.
Lecture 7 Dialog Controls MDI Parent/Child Interaction.
Objects First With Java A Practical Introduction Using BlueJ Handling errors 1.0.
3 4 private void loadButton_Click(object sender, RoutedEventArgs e) { string url = " + nameTextBox.Text.
private void mailButton_Click(object sender, RoutedEventArgs e) { sendMail("From JotPad", jotTextBox.Text); }
[ServiceContract] public interface IJokeOfTheDayService { [OperationContract] string GetJoke(int jokeStrength); }
3 4 5 resultTextBlock.Text = result.ToString();
Vaughan Knight Vaughan Knight Bit
Text Files and String Processing
3 private void equalsButton_Click( object sender, RoutedEventArgs e) { calculateResult(); }
WebClient client; 10 // Constructor public MainPage() { InitializeComponent(); client = new WebClient(); client.DownloadStringCompleted.
Lecture 14: File I/O Common Dialogs Toolbox Widgets.
Architecture Multi Layered Architecture (n-tier): Application: Model Controllers Database Access Graphical User Interface (GUI): Forms, components, controls.
CSC 298 Streams and files.
private void Application_Launching(object sender, LaunchingEventArgs e) { } private void Application_Activated(object.
Milestones  Investigate Methods for AI development(week 2)  Revise initial design (week 3)  Develop functions to generate specific types of data: (week.
private void page2Button_Click(object sender, RoutedEventArgs e) { NavigationService.Navigate(new Uri("/PageTwo.xaml", UriKind.RelativeOrAbsolute));
Module 13: Properties and Indexers. Overview Using Properties Using Indexers.
Int fact (int n) { If (n == 0) return 1; else return n * fact (n – 1); } 5 void main () { Int Sum; : Sum = fact (5); : } Factorial Program Using Recursion.
Files and Streams. What is a file? Up until now, any stored data within a program is lost when the program closes. A file is a permanent way to store.
CPSC 252 Tables / Maps / Dictionaries Page 1 Tables, Maps and Dictionaries A table (or map or dictionary) is a collection of key/value pairs. In general.
Test1 Here some text. Text 2 More text.
Phone: + 40 (728) | +40 (733)
Files and Streams.
[0] [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13]
Dosyalar.
null, true, and false are also reserved.
Gathering User Input Event Handling Create Dynamic controls
[type text here] [type text here] [type text here] [type text here]
Your text here Your text here Your text here Your text here Your text here Pooky.Pandas.
Your text here Your text here Your text here Your text here
Web Service.
[type text here] [type text here] [type text here] [type text here]
មេរៀនទី១១ FILE C/C++ for beginner រៀបចំ និងបង្រៀនដោយ៖ អ៊ិន សុភា
Part 2 Saving the Dictionary
Files and Streams.
Headline will go here Get in touch with us! Subhead Subhead Subhead
Presentation transcript:

3

4

private void saveButton_Click(object sender, RoutedEventArgs e) { saveText("jot.txt", jotTextBox.Text); }

private void saveText(string filename, string text) { using (IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication()) { using (IsolatedStorageFileStream rawStream = isf.CreateFile(filename)) { StreamWriter writer = new StreamWriter(rawStream); writer.Write(text); writer.Close(); } } }

private void loadButton_Click(object sender, RoutedEventArgs e) { string text; if ( loadText("jot.txt", out text ) ) { jotTextBox.Text = text; } else { jotTextBox.Text = "Type your jottings here...."; } }

try { using (IsolatedStorageFileStream rawStream = isf.OpenFile(filename, System.IO.FileMode.Open)) { StreamReader reader = new StreamReader(rawStream); result = reader.ReadToEnd(); reader.Close(); } } catch { return false; }

12

13

14

15

class Person { public string Name; public string Address; public string Phone; }

Dictionary Personnel = new Dictionary ();

Person p1 = new Person { Name = "Rob", Address = "His House", Phone = "1234" }; Personnel.Add(p1.Name, p1);

Person findPerson = Personnel["Rob"];

if (Personnel.ContainsKey("Jim")) { // If we get here the dictionary // contains Jim }

21

22

private void saveText(string filename, string text) { IsolatedStorageSettings isolatedStore = IsolatedStorageSettings.ApplicationSettings; isolatedStore.Remove(filename); isolatedStore.Add(filename, text); isolatedStore.Save(); }

27

28

private bool loadText(string filename, out string result) { IsolatedStorageSettings isolatedStore = IsolatedStorageSettings.ApplicationSettings; result = ""; try { result = (string)isolatedStore[filename]; } catch { return false; } return true; }

30 result = ""; try { result = (string) isolatedStore[filename]; } catch { return false; }

31

32

33