C# 第八次作业

这节课,我们学习了Stream的相关内容。

首先是Stream的大体介绍:.NET Framework provides Files and directories classes. These classes provide methods and properties for creating, naming, manipulating, and deleting files and directories on your disk, or Network. And it provides extensive support for serialization to create a stream of data(variables and objects). The .NET Framework provides buffered and unbuffered streams, and classes for asynchronous I/O.

关于file和directory:

1. Classes provided for file and directory manipulation.

2. The classes you need are in the System.IO namespace.

3. File class: Represents a file on disk.

4. Directory class: Represents a directory (Windows folder).

继承此类的对象可以跨越应用程序域边界被引用,甚至被远程引用。远程调用时, 将产生一个远程对象在本地的透明代理,通过此代理来进行远程调用。 使用代理交换消息来跨应用程序域边界进行通讯的对象的基类。

Working with Directories:

1. The Directory class exposes static methods for creating, moving, and exploring directories.

2. All the methods of the Directory class are static; therefore, you can call them all without having an instance of the class.

3. The DirectoryInfo class is a similar class, but one that has nothing but instance members (i.e.,no static members at all).

4. The FileSystemInfo class has a number of properties and methods that provide information about a file or directory.

Creating a DirectoryInfo:

1. Object To explore a directory hierarchy, you need to instantiate a DirectoryInfo object.

2. The DirectoryInfo class provides methods for getting not just the names of contained files and directories, but also FileInfo and DirectoryInfo objects, allowing you to dive in to the hierarchical structure, extracting subdirectories and exploring these recursively.

Working with Files:

1. The DirectoryInfo object can also return a collection of all the files in each subdirectory found.

2. The DirectoryInfo.GetFiles( ) method returns an array of FileInfo objects, each of which describes a file in that directory.

3. The FileInfo and File objects relate to one another, much as DirectoryInfo and Directory do.

4. Like the methods of Directory, all the File methods are static.

5. Like DirectoryInfo, all the methods of FileInfo are instance methods.

然后我试着运用了一下DirectoryInfo▼

其中

1. 从环境变量"SystemRoot"中得到特定字符串的值

string theDirectory = Environment.GetEnvironmentVariable("SystemRoot");

2.得到目录字符串theDirectory的对象

dir DirectoryInfo dir = new DirectoryInfo(theDirectory );

3.得到dir目录对象的文件集合

FileInfo[] filesInDir = dir.GetFiles();

4.得到dir对象的子目录集合

DirectoryInfo[] directories = dir.GetDirectories();

Principal methods of the Directory class:

CreateDirectory() :Creates all directories and subdirectories specified by its path parameter

GetCreationTime() :Returns and sets the time the specified directory was created

GetDirectories() :Gets named directories

GetLogicalDrives() :Returns the names of all the logical drives in the form <drive>:\

GetFiles() :Returns the names of files matching a pattern

GetParent() :Returns the parent directory for the specified path

Move() :Moves a directory and its contents to a specified path

Principal methods and properties of the DirectoryInfo class:

Attributes: Inherits from FileSystemInfo; gets or sets the creation time of the current file

CreationTime: Inherits from FileSystemInfo; gets or sets the creation time of the current file

Exists: Public property Boolean value, which is true if the directory exists

Extension: Public property inherited from FileSystemInfo; that is, the file extension

FullName: Public property inherited from FileSystemInfo; that is, the full path of the file or directory

LastAccessTime: Public property inherited from FileSystemInfo; gets or sets the last access time

LastWriteTime: Public property inherited from FileSystemInfo; gets or sets the time when the current file or directory was last written to

Name: Public property name of this instance of DirectoryInfo

Parent:  Public property parent directory of the specified directory

Root:  Public property root portion of the path

Create(): Public method that creates a directory

CreateSubdirectory(): Public method that creates a subdirectory on the specified path

Delete() : Public method that deletes a DirectoryInfo and its contents from the path

GetDirectories() : Public method that returns a DirectoryInfo array with subdirectories

GetFiles() :Public method that returns a list of files in the directory

GetFileSystemInfos() :Public method that retrieves an array of FileSystemInfo objects

MoveTo() :Public method that moves a DirectoryInfo and its contents to a new path

Refresh() :Public method inherited from FileSystemInfo; refreshes the state of the object

Principal public static methods of the File class:

AppendText() :Creates a StreamWriter that appends text to the specified file

Copy() : Copies an existing file to a new file

Create() :Creates a file in the specified path

CreateText() :Creates a StreamWriter that writes a new text file to the specified file

Delete() :Deletes the specified file

Exists() :Returns true if the specified file exists

GetAttributes(), SetAttributes() :Gets or sets the FileAttributes of the specified file

GetCreationTime(), SetCreationTime() :Returns or sets the creation date and time of the file

GetLastAccessTime(), SetLastAccessTime() :Returns or sets the last time the specified file was accessed

GetLastWriteTime(), SetLastWriteTime() :Returns or sets the last time the specified file was written to

Move() :Moves a file to a new location; can be used to rename a file

OpenRead() :Public static method that opens a FileStream on the file

OpenWrite() :Creates a read/write Stream on the specified path

Principal methods and properties of the FileInfo class:

Attributes() :Inherits from FileSystemInfo; gets or sets the attributes of the current file

CreationTime :Inherits from FileSystemInfo; gets or sets the creation time of the current file

Directory :Public property that gets an instance of the parent directory

Exists :Public property Boolean value that is true if the directory exists

Extension :Public property inherited from FileSystemInfo; that is, the file extension

FullName :Public property inherited from FileSystemInfo; that is, the full path of the file or directory

LastAccessTime :Public property inherited from FileSystemInfo; gets or sets the last access time

LastWriteTime :Public property inheritedfrom FileSystemInfo; gets or sets the time when the current file or directory was last written to

Length :Public property that gets the size of the current file

Name :Public property Name of this DirectoryInfo instance

AppendText() :Public method that creates a StreamWriter that appends text to a file

CopyTo() :Public method that copies an existing file to a new file

Create() :Public method that creates a new file

Delete() :Public method that permanently deletes a file

MoveTo() :Public method to move a file to a new location; can be used to rename a file

Open() :Public method that opens a file with various read/write and sharing privileges

OpenRead() :Public method that creates a read-only FileStream

OpenText() :Public method that creates a StreamReader that reads from an existing text file

OpenWrite() :Public method that creates a write-only FileStream

其实感觉这四部分大部分的都差不多……只有少数的几个是不一样的。

之后我们学习了关于改变文件读写数据一类的,因为还有一堆presentation没做怕玩脱了把电脑玩坏了就没做。

时间: 2024-11-10 11:35:46

C# 第八次作业的相关文章

耿丹16-1第八次作业

-- Deadline: 2016-11-14 20:00pm -- 作业内容:https://edu.cnblogs.com/campus/bjgygd/Sixteen-One/homework/178 -- 第八次作业总结: 1. 这次作业发布有些迟,所以迟交的同学,我目前没有扣分数,部分同学还未来得及交作业,请补上. 2. 表扬111.125.117.131.109.101.107.119等同学. 3. 大家遇到不会的题,参考别人代码时,请注明下!并且请认真验证,思考下程序的正确性!一定要

软件过程与项目管理第八次作业

软件项目与过程管理第八周作业 我们的小组项目已经基本完成了,这周我们小组的主要工作就是做测试和写测试文档. 我的主要任务是测试一些接口的功能,包括:Graph.Movies.System等等一些模块的接口,测试用的语言是lua,lua在上周已经简单的了解学习了一下.我们的测试主要用的是黑盒测试的边界值法.如对图片透明值的测试,GraphSetAlpha(int idx, int a)这个接口,设定一张指定图片的id后,我就将alpha值设置为小于0,等于0,0到225之间,225,大于225这么

3.30日第八次作业,第14章,采购管理,15章,信息文档和配置管理

3.30日第八次作业,第14章,采购管理,15章,信息文档和配置管理   第14章.采购管理1.采购管理包括哪些过程?(记)P382-383 答:1).编制采购计划.2).编制询价计划.3).询价.招投标.4).供方选择.5).合同管理.6).合同收尾. 2.编制采购计划过程的成果是什么?P386-387 答:1).采购管理计划.2).采购工作说明书. 3.判断:每个采购工作说明书都来自于项目范围基准.P387 答:是的. 4.结合P388页表14-1,工作说明书应该清楚地描述哪些内容?P388

14软件工程第八次作业

一点感悟 项目已经完工近一个星期了,这时候才写第八周作业好像有点晚. 可最开始真不知道该写些什么,又不想粘贴几个代码了事,所以一直拖到今天. 我这个人是有拖延症的.这病好像在我这儿就是绝症--没救了!项目最开始的时候,写立项书明书,写需求说明书,自己都是最拖拉的几个中的一个.明明就一两百字就可以解决的问题,总是一拖再拖.最后拖到自己写哪部分都差不多忘了.除了写书,设计代码时也拖,可以说前面几周我们根本没做什么,就后面两三周才真正做出了点东西--一点自己都不太好意思拿出手的项目. 我自认为在这个项

2017-2018-1 JAVA实验站 第八周作业

2017-2018-1 JAVA实验站 第八周作业 团队分工 UML 用例图 类图 活动图 状态图 工具选择 windows系统自带的画图软件 ProcessOn

2018-4-29 第八周作业

2018-4-29 第八周作业 网络攻防环境搭建 第八周作业: =网络攻防环境搭建 教材学习: 本次介绍了linux基本架构,Linux的远程攻防技术,Linux系统结构. 具体可以参考一下链接. =linux基本架构 =linux系统结构 kali视频课: SET工具的使用 嗅探欺骗,中间人攻击: 原文地址:https://www.cnblogs.com/nalanruntu/p/8970433.html

软件工程_东师站_第八周作业

一.PSP Date Type Job Start Interrupt(min) End Total(min) 20160417 助教 黄金点 20:00 5 21:00 55 20160418 助教 黄金点 19:00 12 21:00 108 20160419 助教 黄金点 18:45 100 23:00 155 20160420 助教 团队作业 10:00 35 11:20 45 20160425 结对编程 四则运算 19:00 5 19:30 25 ? 二.进度条 ? 代码行数 博客字数

软件项目与过程管理第八周作业

内容:软件项目与过程管理课程内容总结 经过八周时间的学习,软件项目与过程管理课程已经逐渐接近了尾声.通过这八周的学习,我对软件项目与过程管理课程有了更深的理解. 一.关于团队项目. 团队项目是本次软件项目与过程管理课程中最重要的一部分.我们团队项目是作业管理系统.在项目开发的整个过程中,我们在项目经理的带领下,项目团队的每一个成员团结合作.相互沟通,团队成员之间相互学习彼此的优点和技术,在每个成员的共同努力下,基本完成了此次软件开发项目. 通过这次团队项目, 我的总结如下: 1.在项目的开发过程

第八周作业大全

1.数字逻辑 p85 .3-3 p87.3-15 3-17(2),3-21. 本子还没发,具体交的时间等老师发给我作业再告诉大家,可以先去做 2.操作系统 p113 10.试... p114 18.20.41 p120 25 作业上交时间是5月3号 3.web 老师上周布置的要实现登陆页面和获取登陆页面信息的任务 没有通过的继续写 作业上交时间4月31号 4.软件工程 看老师的博客园 5.英语 阅读先去复习(德海兄班的)

20169217 《Linux内核原理与分析》 第八周作业

此次作业仍然分为两个部分,第一部分为实验. 实验要求: 1. 阅读理解task_struct数据结构.   2. 分析fork函数对应的内核处理过程sys_clone,理解创建一个新进程如何创建和修改task_struct数据结构.   3.使用gdb跟踪分析一个fork系统调用内核处理函数sys_clone ,验证对Linux系统创建一个新进程的理解. 实验内容: 1.理解task_struct数据结构. 操作系统内核里面有操作系统所谓的三大功能,就是进程管理,内存管理和文件系统.但这里面最核