File Systems Files and directories Absolute and relative names Text and binary files Sequential-access and random-access files.

Slides:



Advertisements
Similar presentations
Pemrograman VisualMinggu …12… Page 1 MINGGU Ke Duabelas Pemrograman Visual Pokok Bahasan: File and Stream Tujuan Instruksional Khusus: Mahasiswa dapat.
Advertisements

Object Oriented Programming Files and Streams Dr. Mike Spann
C# - Files and Streams Outline Files and Streams Classes File and Directory Creating a Sequential-Access File Reading Data from a Sequential-Access.
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.
Serialization objects created in a program reside in RAM through references object o; heap stack content.
ASP.NET Programming with C# and SQL Server First Edition
Creating Sequential-Access File  Serializable attribute indicates to the compiler that objects of a class can be serialized– written to or read from a.
Sequential-access file Create, read and write an object into a sequential-access file Serialize and deserialize the object to write and read from a data.
C# Programming: From Problem Analysis to Program Design1 Working with Files C# Programming: From Problem Analysis to Program Design 3 rd Edition 13.
File and Streams There are many ways of organizing records in a file. There are many ways of organizing records in a file. The most common type of organization.
MIS316 – BUSINESS APPLICATION DEVELOPMENT – Chapter 14 – Files and Streams 1Microsoft Visual C# 2012, Fifth Edition.
2. I/O Text Files CCSA225 - Advanced Java Programming Sarah Alodan
Understanding Input/Output (I/O) Classes Lesson 5.
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.
Lecture Set 12 Sequential Files and Structures Part B – Reading and Writing Sequential Files.
1 Binary Files ผศ. ดร. หมัดอามีน หมันหลิน Faculty of IST, MUT
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.
Using Arrays and File Handling
CIS 270—Application Development II Chapter 14—Files and Streams.
 2006 Pearson Education, Inc. All rights reserved Files and Streams.
1 14/10/58Dr.Mud-Armeen Munlin 1 Files and Streams ผศ. ดร. หมัดอามีน หมันหลิน Faculty of IST, MUT
Streams & File Input/Output Basics C#.Net Development Version 1.1.
Reference: Lecturer Lecturer Reham O. Al-Abdul Jabba lectures for cap211 Files and Streams- I.
Object Oriented Software Development 10. Persistent Storage.
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.
Lecture 19 Serialization Richard Gesick. Serialization Sometimes it is easier to read or write entire objects than to read and write individual fields.
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.
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,
Input and Output 23: Input and Output
CSC 298 Streams and files.
Chapter 21 – Files and Streams 1 Outline Files and Streams Classes File and Directory Creating a Sequential-Access File Reading Data from a Sequential-Access.
Ajay Tripathi Input Output. Ajay Tripathi Input/output (IO) refers to the operations for reading and writing data to streams and files. In the.NET Framework,
McGraw-Hill © 2010 The McGraw-Hill Companies, Inc. All rights reserved. Chapter 11 Data Files.
CSCI 3328 Object Oriented Programming in C# Chapter 11: Files and Streams 1 Xiang Lian The University of Texas Rio Grande Valley Edinburg, TX 78539
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.
Strings in C++/CLI us/library/system.string.aspxhttp://msdn.microsoft.com/en- us/library/system.string.aspx public: static.
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 Programming For CCS 301 course Dr. Ahmad ABDELHAY.
Chapter 6: Creating Windows–based Applications 1 Microsoft® Visual C# 2008.
Lecture 18 File I/O Richard Gesick. File Input / Output Consider that a program may want to make its data persistent (or not rely upon the user for input)
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.
INF230 Basics in C# Programming
Module 6: Building .NET–based Applications with C#
Input and Output 23: Input and Output
Advanced .NET Programming II 6th Lecture
C# Programming: From Problem Analysis to Program Design
18 Files and Streams.
How to work with files and data streams
CSCI 3327 Visual Basic Chapter 11: Files and Streams
Files and Streams Lect3 CT1411.
Sequential Input and Output using Text Files
File Input/Output (I/O)
טיפול בקבצים ליווי מקצועי : ארז קלר
Files & Streams.
The University of Texas – Pan American
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.
Object Oriented Programming
Files and Streams Lect10 GC201 12/1/2015.
Lecture 16 File I/O Richard Gesick.
Fundaments of Game Design
How to work with files and data streams
CSCI 3328 Object Oriented Programming in C# Chapter 11: Files and Streams UTPA – Fall 2012 This set of slides is revised from lecture slides of Prof.
Chapter 11 Saving Data and Objects In Files
Lecture 18 File I/O CSE /5/2019.
Presentation transcript:

File Systems Files and directories Absolute and relative names Text and binary files Sequential-access and random-access files

File System Input and Output One time access vs over-a-period-of- time access One time: call a static member function Over-a-period-of- time: create an instance of a class Classes for Files File FileInfo Classes for Directories Directory DirectoryInfo

File and FileInfo in C++/CLI File::Exists(path) FileInfo^ file = gcnew FileInfo( path ); file->Exists file->FullName file->Length file->Directory file->isReadOnly file->CopyTo( path2 ) us/library/system.io.file.aspx us/library/system.io.fileinfo.aspx

Directory and DirectoryInfo in C++/CLI Directory::Exists(path) DirectoryInfo^ dir=gcnew DirectoryInfo(path); dir->Exists dir->FullName dir->Parent array ^ GetFiles() array ^ GetDirectories() us/library/system.io.directory.aspx us/library/system.io.directoryinfo.aspx

Opening Files and I/O Open, Create, OpenRead, etc. Open Methods –Mode: Append, Create, CreateNew, Open, etc –Access: Read, Write, ReadWrite –Share: None, Read, Write, ReadWrite Stream, FileStream, StreamWriter, StreamReader

Sequential-access Text File in C++/CLI StreamReader ^sr = File::OpenText(name); // or: StreamReader ^sr = gcnew StreamReader(name); sr->Read();// read one char sr->ReadLine();// read one line sr->Close() StreamWriter ^sw = gcnew StreamWriter(name); sw->Write(“string”); sw->WriteLine(“string”); sw->Close()

Object Serialization in C++/CLI Dealing with complex classes [Serializable] ref class MyObject {} BinaryFormatter: using namespace System::Runtime::Serialization::Formatters::Binary; SoapFormatter: // Simple Objet Access Protocol, XML #using using namespace System::Runtime::Serialization::Formatters::Soap;

Object Serialization in C++/CLI cont’d Serialization steps: BinaryFormatter ^bf = gcnew BinaryFormatter() // SoapFormatter, XML-based FileStream output = File::Create(name); bf->Serialize(output, obj); // Store MyObject obj; output.close(); BinaryFormatter ^bf = gcnew BinaryFormatter() FileStream input = File::OpenRead(name); MyObject^ obj = (MyObject^)bf->Deserialize(input); //Restore MyObject obj input.close();

An Example … Also, Command line parameters: “Project” -> “Properties” -> “Configuration Properties” -> “Debugging” –On that page, find “Command Arguments”, add the file name

Common File Dialog Boxes OpenFileDialog us/library/system.windows.forms.openfiledi alog.aspxhttp://msdn.microsoft.com/en- us/library/system.windows.forms.openfiledi alog.aspx SaveFileDialog us/library/system.windows.forms.savefiledi alog.aspxhttp://msdn.microsoft.com/en- us/library/system.windows.forms.savefiledi alog.aspx