Thư viện tri thức trực tuyến
Kho tài liệu với 50,000+ tài liệu học thuật
© 2023 Siêu thị PDF - Kho tài liệu học thuật hàng đầu Việt Nam

Chapter 13 - File IO and Isolated Storage pps
Nội dung xem thử
Mô tả chi tiết
Chapter 13. File I/O and
Isolated Storage
Hoang Anh Viet
Hanoi University of Technology
1
Microsoft
Objectives
“The System.IO namespace allows you to interact with a machine’s file
and directory structure. Over the course of this chapter, you will
learn how to programmatically create (and destroy) a directory
system as well as move data into and out of various streams (file
based, string based, memory based, etc.). The latter part of this
chapter examines the role of isolated storage, which allows you to
persist per-user data into a safe sandbox, regardless of the security
settings of a target machine. To understand certain aspects of the
System.IO.IsolatedStorage API, you will also receive an overview of
Code Access Security (CAS).…”
2
Microsoft
Roadmap
1. Exploring the System.IO namespace
2. Working with File System
3. The Abstract System Class
4. Working with StreamWriters and StreamReaders
5. Working with StringWriters and StringReaders
6. Working with BinaryWriters and BinaryReaders
7. Programmatically “Watching” Files
8. Performing Asynchronous File I/O
9. An Overview of Isolated Storage
10. Introducing Object Serialization
3
Microsoft
13.1 Exploring the System.IO namespace
System.IO namespace is the region of the base class
libraries devoted to file-based (and memory-based) input
and output (I/O) services
System.IO defines a set of classes, interfaces,
enumerations, structures, and delegates, most of which
are contained in mscorlib.dll
4
Microsoft 5
Nonabstract I/O Class
Type
Description
BinaryReader, BinaryWriter These types allow you to store and retrieve primitive data types
(integers, Booleans, strings, and whatnot) as a binary value.
BufferedStream This type provides temporary storage for a stream of bytes that may
be committed to storage at a later time
Directory, DirectoryInfo These types are used to manipulate a machine’s directory structure.
The Directory type exposes functionality using static members. The
DirectoryInfo type exposes similar functionality from a valid object
reference.
DriveInfo This type provides detailed information regarding the drives used by a
given machine.
File, FileInfo These types are used to manipulate a machine’s set of files. The File
type exposes functionality using static members. The FileInfo type
exposes similar functionality from a valid object reference.
FileStream This type allows for random file access (e.g., seeking capabilities)with
data represented as a stream of bytes.
Figure 13.1 Key Members of the System.IO Namespace
Microsoft 6
Nonabstract I/O Class
Type
Description
FileSystemWatcher This type allows you to monitor the modification of external files in a
specified directory.
MemoryStream This type provides random access to streamed data stored in memory
rather than a physical file.
Path This type performs operations on System.String types that contain file
or directory path information in a platform-neutral manner.
StreamWriter, StreamReader These types are used to store (and retrieve) textual information to (or
from) a file. These types do not support random file access.
StringWriter, StringReader Like the StreamReader/StreamWriter types, these classes also work
with textual information. However, the underlying storage is a string
buffer rather than a physical file.
Figure 13.1 Key Members of the System.IO Namespace (Cont.)