Chapter 14: Files and Streams. 2Microsoft Visual C# 2012, Fifth Edition Files and the File and Directory Classes Temporary storage – Usually called computer.

Slides:



Advertisements
Similar presentations
P3- Represent how data flows around a computer system
Advertisements

File Handling Advanced Higher Programming. What is a file? Up until now, any stored data within a program is lost when the program closes. A file is a.
Computer Architecture. Central Processing Unit (CPU)- micro processor The Personal Computer.
Chapter 9: Sequential Access Files and Printing
Copyright © 2012 Pearson Education, Inc. Chapter 1: Introduction to Computers and Programming.
An Introduction to Programming with C++ Fifth Edition Chapter 13 Sequential Access Files.
Chapter 1- Visual Basic Schneider1 Chapter 1 An Introduction to Computers and Visual Basic.
Starting Out with C++: Early Objects 5/e © 2006 Pearson Education. All Rights Reserved Starting Out with C++: Early Objects 5 th Edition Chapter 1 Introduction.
MIS316 – BUSINESS APPLICATION DEVELOPMENT – Chapter 14 – Files and Streams 1Microsoft Visual C# 2012, Fifth Edition.
CS 0008 Day 2 1. Today Hardware and Software How computers store data How a program works Operators, types, input Print function Running the debugger.
Copyright © 2012 Pearson Education, Inc. Chapter 1: Introduction to Computers and Programming.
Alternate Version of STARTING OUT WITH C++ 4 th Edition Chapter 1 Introduction to Computers and Programming.
Chapter Introduction to Computers and Programming 1.
CCE-EDUSAT SESSION FOR COMPUTER FUNDAMENTALS Faculty: Anita Kanavalli Department of CSE M S Ramaiah Institute of Technology Bangalore E mail-
CSC 125 Introduction to C++ Programming Chapter 1 Introduction to Computers and Programming.
Computer Systems Week 10: File Organisation Alma Whitfield.
Topics Introduction Hardware and Software How Computers Store Data
Programming Logic and Design Seventh Edition
Copyright © 2012 Pearson Education, Inc. Chapter 1: Introduction to Computers and Programming.
Chapter 1: Introduction to Computers and Programming.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 1: Introduction to Computers and Programming.
CIS 270—Application Development II Chapter 14—Files and Streams.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with C++ Early Objects Seventh Edition by Tony Gaddis, Judy.
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 1 Introduction to Computers and Programming.
Chapter 11 File Systems and Directories. 2 File Systems File: A named collection of related data. File system: The logical view that an operating system.
File Systems (1). Readings r Reading: Disks, disk scheduling (3.7 of textbook; “How Stuff Works”) r Reading: File System Implementation ( of textbook)
Data Structure & File Systems Hun Myoung Park, Ph.D., Public Management and Policy Analysis Program Graduate School of International Relations International.
File Handling and Control Break Logic. Objectives In this chapter, you will learn about: Computer files Writing a program that reads from and/or writes.
Operating Systems COMP 4850/CISG 5550 File Systems Files Dr. James Money.
Reference: Lecturer Lecturer Reham O. Al-Abdul Jabba lectures for cap211 Files and Streams- I.
Object Oriented Software Development 10. Persistent Storage.
 Bits & Bytes Bits & Bytes  Units of data Units of data  Storage devices Storage devices  Storage Types Storage Types  Secondary Storage Secondary.
Computer Programming TCP1224 Chapter 13 Sequential File Access.
Files and Streams. Objectives Learn about the classes that support file input/output Understand the concept of abstraction and how it related to the file.
GCSE ICT Storing data - Internal memory, backing storage, and measuring memory.
Copyright 2003 Scott/Jones Publishing Standard Version of Starting Out with C++, 4th Edition Chapter 1 Introduction to Computers and Programming.
Chapter 1: Overview of SAS System Basic Concepts of SAS System.
Measuring Memory and Storage
1 Exceptions Exception handling – Exception Indication of problem during execution – E.g., divide by zero – Chained exceptions Uses of exception handling.
 Learn about computer files  Use the Path class  Learn about  Streams  Buffers  file organization  Use Java’s IO classes to write to and read from.
BACS 287 File-Based Programming. BACS 287 Data Hierarchy  Database - Collection of files, relationships, integrity information, etc  Files - All records.
Chapter 11 File Systems and Directories. 2 File Systems (Chapter 11.1) File: 1. A named collection of related data. 2.smallest amount of information that.
BMTS 242: Computer and Systems Lecture 2: Memory, and Software Yousef Alharbi Website
Files in Python The Basics. Why use Files? Very small amounts of data – just hardcode them into the program A few pieces of data – ask the user to input.
DATA MANAGEMENT 1) File StructureFile Structure 2) Physical OrganisationPhysical Organisation 3) Logical OrganisationLogical Organisation 4) File OrganisationFile.
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.
Java Programming, Second Edition Chapter Sixteen File Input and Output.
Copyright © 2014, 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with C++ Early Objects Eighth Edition by Tony Gaddis,
C++ Programming: From Problem Analysis to Program Design, Fifth Edition Chapter 1: An Overview of Computers and Programming Languages.
Files and Streams Lec Introduction  Files are used for long-term retention of large amounts of data, even after the program that created the.
Information Technology (IT). Information Technology – technology used to create, store, exchange, and use information in its various forms (business data,
A+ Guide to Managing and Maintaining Your PC, 7e Chapter 1 Introducing Hardware.
Chapter 1: Introduction to Computers and Programming
Chapter 1: An Overview of Computers and Programming Languages
Topics Introduction Hardware and Software How Computers Store Data
A+ Guide to Managing and Maintaining Your PC, 7e
CSCI 3327 Visual Basic Chapter 11: Files and Streams
Files and Streams.
Chapter 13: File Input and Output
Files and Streams Lect3 CT1411.
Chapter 1: Introduction to Computers and Programming
Programming Logic and Design Eighth Edition
MSIS 670: Object-Oriented Software Engineering
Computer Based Technology:
Topics Introduction Hardware and Software How Computers Store Data
Week 1: File Systems and Directories
Files and Streams Lect10 GC201 12/1/2015.
Files and Streams.
Chapter 1: Introduction to Computers and Programming
Presentation transcript:

Chapter 14: Files and Streams

2Microsoft Visual C# 2012, Fifth Edition Files and the File and Directory Classes Temporary storage – Usually called computer memory or random access memory (RAM) – Variables use temporary storage – Volatile Permanent storage – Data is not lost when a computer loses power – Nonvolatile – The program is saved to a disk

3Microsoft Visual C# 2012, Fifth Edition Files and the File and Directory Classes (cont’d.) Text files – Contain information in ASCII or Unicode characters Can be read in a plain text editor Can be data files or source code files (e.g., C# source code) Binary files – Store software, images, music, etc.

4Microsoft Visual C# 2012, Fifth Edition Files and the File and Directory Classes (cont’d.) Characteristics of a file – Occupies space on a section of a storage device – Has a name, a size, a type, and a specific time of creation Write to the file – Store data in a file on a persistent storage device Read from the file – Copy data from a file on a storage device into RAM Computer users organize their files into folders or directories

5Microsoft Visual C# 2012, Fifth Edition Files and the File and Directory Classes (cont’d.) Path – A combination of the disk drive plus the complete hierarchy of directories in which a file resides Example: C:\C#\Chapter.14\Data.txt C# provides built-in classes named File and Directory – Contain methods to help you manipulate files and their directories Access information about files Create, delete, or move files

6Microsoft Visual C# 2012, Fifth Edition Using the File and Directory Classes File class – Contains methods to access information about files – Contained in the System.IO namespace Directory class – Provides information about directories or folders

7Microsoft Visual C# 2012, Fifth Edition Using the File and Directory Classes (cont’d.)

8Microsoft Visual C# 2012, Fifth Edition

9 Using the File and Directory Classes (cont’d.)

10Microsoft Visual C# 2012, Fifth Edition Using the File and Directory Classes (cont’d.)

11Microsoft Visual C# 2012, Fifth Edition

12Microsoft Visual C# 2012, Fifth Edition Using the File and Directory Classes (cont’d.)

13Microsoft Visual C# 2012, Fifth Edition Understanding File Data Organization Businesses store data in a relationship known as the data hierarchy Character – Any of the letters, numbers, or other special symbols (such as punctuation marks) that comprise data – Characters are made up of bytes containing eight (8) bits ASCII characters contain one (1) byte Unicode characters contain two (2) bytes

14Microsoft Visual C# 2012, Fifth Edition Understanding File Data Organization (cont’d.)

15Microsoft Visual C# 2012, Fifth Edition Field – A character or group of characters that has some meaning Record – A collection of related fields that contain data about an entity Data files – Consist of related records Understanding File Data Organization (cont’d.)

16Microsoft Visual C# 2012, Fifth Edition A C# application opens a file by creating an object and associating a stream of bytes with that object When you finish using a file, the program should close the file – Not closing a file may make it inaccessible – Not closing an output file can result in data not being written to the file Understanding File Data Organization (cont’d.)

17Microsoft Visual C# 2012, Fifth Edition Understanding Streams Stream – Functions as a pipeline or channel between an input device and an application, and potentially an output device

18Microsoft Visual C# 2012, Fifth Edition Understanding Streams (cont’d.) Most streams flow in only one direction – StreamReader for text input from a file – StreamWriter for text output to a file – FileStream for both input from and output to a file

19Microsoft Visual C# 2012, Fifth Edition Understanding Streams (cont’d.)

20Microsoft Visual C# 2012, Fifth Edition Understanding Streams (cont’d.)

21Microsoft Visual C# 2012, Fifth Edition Understanding Streams (cont’d.)

22Microsoft Visual C# 2012, Fifth Edition Understanding Streams (cont’d.)

23Microsoft Visual C# 2012, Fifth Edition Delimiter – A character used to specify the boundary between records and, potentially, fields in text files When you write data to a text file: – You can separate the fields with a delimiter – Delimiters are needed when fields are not fixed in size and position—field size varies – CSV files (comma-separated value files) are delimited files Writing Data to a Sequential Access Text File

24Microsoft Visual C# 2012, Fifth Edition Writing Data to a Sequential Access Text File (Using Classes)

25Microsoft Visual C# 2012, Fifth Edition

26Microsoft Visual C# 2012, Fifth Edition Writing Data to a Sequential Access Text File (cont’d.)

27Microsoft Visual C# 2012, Fifth Edition Writing Data to a Sequential Access Text File (cont’d.)

28Microsoft Visual C# 2012, Fifth Edition Reading from a Sequential Access Text File Reading from a text file is similar to writing to a text file Classes used: – FileStream – StreamReader

29Microsoft Visual C# 2012, Fifth Edition 29

30Microsoft Visual C# 2012, Fifth Edition Reading from a Sequential Access Text File (cont’d.)