File Input/Output (I/O)

Slides:



Advertisements
Similar presentations
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Outline 24.1 Test-Driving the Ticket Information Application.
Advertisements

Reading and Writing Text Files Svetlin Nakov Telerik Corporation
Pemrograman VisualMinggu …12… Page 1 MINGGU Ke Duabelas Pemrograman Visual Pokok Bahasan: File and Stream Tujuan Instruksional Khusus: Mahasiswa dapat.
Chapter 11 Data Files Copyright © 2011 by The McGraw-Hill Companies, Inc. All Rights Reserved. McGraw-Hill.
Files & Streams. Files Introduction Files are used for long-term retention of large amounts of data, even after the program that created the data terminates.
IS 1181 IS 118 Introduction to Development Tools VB Chapter 06.
Chapter 9: Sequential Access Files and Printing
Using Multiple Forms. Creating a New Form ProjectAdd Windows Form.
File Systems Files and directories Absolute and relative names Text and binary files Sequential-access and random-access files.
C# Programming: From Problem Analysis to Program Design1 Working with Files C# Programming: From Problem Analysis to Program Design 3 rd Edition 13.
MIS316 – BUSINESS APPLICATION DEVELOPMENT – Chapter 14 – Files and Streams 1Microsoft Visual C# 2012, Fifth Edition.
Understanding Input/Output (I/O) Classes Lesson 5.
Computer and Programming File I/O File Input/Output Author: Chaiporn Jaikaeo, Jittat Fakcharoenphol Edited by Supaporn Erjongmanee Lecture 13.
Lecture Set 12 Sequential Files and Structures Part B – Reading and Writing Sequential Files.
Visual C Sharp – File I/O - 1 Variables and arrays only temporary - lost when a program terminates Files used for long term storage (Data bases considered.
Chapter 12 Working with Files CIS 3260 Introduction to Programming using C# Hiro Takeda.
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.
Microsoft Visual Basic 2008 CHAPTER NINE Using Arrays and File Handling.
Microsoft Visual Basic 2005 CHAPTER 9 Using Arrays and File Handling.
Using Arrays and File Handling
C# B 1 CSC 298 Writing a C# application. C# B 2 A first C# application // Display Hello, world on the screen public class HelloWorld { public static void.
File I/O 11_file_processing.ppt
Chapter 10: Structures and Sequential Access Files
Chapter Ten Structures and Sequential Access Files Programming with Microsoft Visual Basic th Edition.
File I/O Static void Main( ) {... } data. Topics I/O Streams Reading and Writing Text Files Formatting Text Files Handling Stream Errors File Pointers.
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved Ticket Information Application Introducing Sequential-Access Files.
11-1 aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf.
Chapter Ten Structures and Sequential Access Files Programming with Microsoft Visual Basic th Edition.
Reference: Lecturer Lecturer Reham O. Al-Abdul Jabba lectures for cap211 Files and Streams- I.
File I/O What We’ll Cover –Visual Basic Techniques for Text Files –.NET Techniques for Text Files What We’ll Not Cover –Binary File I/O –XML File I/O.
Object Oriented Software Development 10. Persistent Storage.
File Input and Output (I/O) Engineering 1D04, Teaching Session 7.
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.
Visual Basic 2010 How to Program © by Pearson Education, Inc. All Rights Reserved.
CS360 Windows Programming
Chapter 14: Files and Streams. 2Microsoft Visual C# 2012, Fifth Edition Files and the File and Directory Classes Temporary storage – Usually called computer.
Copyright © 2012 Pearson Education, Inc. Chapter 5 Loops, File, and Random Numbers.
The Professional Touch Programming Right from the Start with Visual Basic.NET 1/e 10.
BIM313 – Advanced Programming File Operations 1. Contents Structure of a File Reading/Writing Texts from/to Files File and Directory Operations 2.
CSCI 3328 Object Oriented Programming in C# Chapter 11: Files and Streams -- Exercises 1 Xiang Lian The University of Texas Rio Grande Valley Edinburg,
Programming with Microsoft Visual Basic 2008 Fourth Edition Chapter Ten Structures and Sequential Access Files.
File IO.  File Input/Output  StreamWriter  StreamReader  Text Files  Binary Files.
McGraw-Hill © 2010 The McGraw-Hill Companies, Inc. All rights reserved. Chapter 11 Data Files.
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.
Object-Oriented Application Development Using VB.NET 1 Chapter 13 Introduction to Data Access Classes and Persistence.
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.
1 Displaying Dialog Boxes Kashef Mughal. 2 Midterm Stats Here we go  Average was  Low was 116  High was 184  Mid Quarter Grade - check any.
Topics discussed in this section:
Reading & writing to files
C# Programming: From Problem Analysis to Program Design
CSCI 3327 Visual Basic Chapter 11: Files and Streams
Files.
Using Multiple Forms.
Defiana Arnaldy, M.Si File and Stream I/O Defiana Arnaldy, M.Si
How to work with files and data streams
Files and Streams.
Files and Streams Lect3 CT1411.
Sequential Input and Output using Text Files
Tonga Institute of Higher Education
Files & Streams.
The University of Texas – Pan American
Chapter 3.5 Input and Output
Open your video file. Play the video.
CSCI 3328 Object Oriented Programming in C# Chapter 11: Files and Streams -- Exercises UTPA – Fall 2012 This set of slides is revised from lecture slides.
Files and Streams Lect10 GC201 12/1/2015.
BO65: PROGRAMMING WRITING TO TEXT FILES.
How to work with files and data streams
Files and Streams.
Chapter 11 Saving Data and Objects In Files
Topics discussed in this section:
Presentation transcript:

File Input/Output (I/O) Tonga Institute of Higher Education

Working with Files and Directories Programs often work with files Changing files or directories Getting information about file or directory Getting data form a file or directory Saving data in a file or directory

System.IO Namespace The System.IO namespace contains many classes we can use to work with files and directories DirectoryInfo FileInfo StreamReader StreamWriter

Demonstration FileInfo

What is a Stream? Stream A stream is a sequence of data Streams are used to move data from one place to another In our computer: You can read from streams. Reading is the transfer of data from a stream into a data structure, such as a variable. You can write to streams. Writing is the transfer of data from a data structure, such as a variable, into a stream. Data Source Destination Stream

Writing and Reading Streams StreamReader – Object allows program to read data from a file using a stream. StreamWriter – Object allows program to write data to a file using a stream.

StreamReader Allows a program to read characters from a file Name of the file that will be read Loads 1 line Always close the file. Close releases any resources used by the system

StreamReader 2 The end of the file is reached when line is nothing

Demonstration StreamReader

StreamWriter Allows a program to write characters to a file Name of the file that will be written WriteLine includes a carriage return Close releases any resources used by the system

Demonstration StreamWriter

File Dialog Boxes Often, a user needs a GUI to select a file to open or enter the name and location of a file to save OpenDialogBox - Provides GUI for selecting a file to open SaveDialogBox - Provides GUI for inputting the name and location of a file to save

Open Dialog Box Provides GUI for selecting a file to open

Open Dialog Box GUI The properties can be set using the GUI There are many properties The properties can be set using the GUI

Open Dialog Box GUI Code But code must be used to display it and handle what the user does with it.

OpenFileDialog with GUI and Code Demonstration OpenFileDialog with GUI and Code

Using OpenFileDialog with Only Code Many developers prefer to create source code when using the OpenFileDialog box This allows the developer to see everything they have done

OpenFileDialog with Only Code Demonstration OpenFileDialog with Only Code