操作系统课程设计报告文件管理系统.doc
《操作系统课程设计报告文件管理系统.doc》由会员分享,可在线阅读,更多相关《操作系统课程设计报告文件管理系统.doc(41页珍藏版)》请在三一文库上搜索。
1、 计算机科学与技术学院课程设计报告 ( 20008 2009 学年度 第 一 学期 )课程名称操作系统课程设计项目名称文件管理系统姓名*学号*专业班级地点教师 一、设计任务及主要技术本设计的目的是通过设计和调试一个简单的文件系统,通过模拟文件操作命令的执行,来模拟文件管理,使学生对主要文件操作命令的实质和执行过程有比较深入的了解,掌握它们的基本实施方法。具体要求如下:设计一个支持n个用户的文件系统,每个用户可拥有多个文件;采用二级或二级以上的多级文件目录管理;对文件应设置存取控制保护方式,如“只能执行”、“允许读”、“允许写”等;系统的外部特征应接近于真实系统,可设置下述文件操作命令:建立文件
2、打开文件、关闭文件、删除文件、读文件、写文件、复制文件、查询目录;通过键盘使用该文件系统,系统应显示操作命令的执行结果。二、设计方案:主要模仿和实现Windows中”我的电脑”的部分功能系统原理框图:一、 实验源码 :using System;using System.Collections.Generic;using System.Text;using System.IO;using System.Collections;namespace FileDirOperate / / 与文件有关的操作类 / public class FileOperate / / Deletes the fil
3、e. / / 要删除的文件全路径 / public bool DeleteFile(string FileFullPath) if (File.Exists(FileFullPath) = true) File.SetAttributes(FileFullPath, FileAttributes.Normal); File.Delete(FileFullPath); return true; else return false; / / Gets the name of the file.包括文件的扩展名 / / 文件的全路径 / public string GetFileName(strin
4、g FileFullPath) if (File.Exists(FileFullPath) = true) FileInfo F = new FileInfo(FileFullPath); return F.Name; else return null; / / Gets the name of the file. / / 文件的全路径 / 是否包含文件的扩展名 / public string GetFileName(string FileFullPath, bool IncludeExtension) if (File.Exists(FileFullPath) = true) FileInf
5、o F = new FileInfo(FileFullPath); if (IncludeExtension = true) return F.Name; else return F.Name.Replace(F.Extension, ); else return null; / / 得到文件的大小 / / FileInfo / public String getFileSize(FileInfo info) if (info.Exists = true) long FL =info.Length; if (FL 1024 * 1024 * 1024) / KB MB GB TB return
6、 System.Convert.ToString(Math.Round(FL + 0.00) / (1024 * 1024 * 1024), 2) + GB; else if (FL 1024 * 1024) return System.Convert.ToString(Math.Round(FL + 0.00) / (1024 * 1024), 2) + MB; else return System.Convert.ToString(Math.Round(FL + 0.00) / 1024, 2) + KB; else return null; / / 得到文件的后缀名 / / FileIn
7、fo / public String getFileExtension(FileInfo info) if (info.Exists = true) String extension=info.Extension; return extension;/.Substring(1); / return extension.Substring(1, extension.Length - 1); else return null; / / Gets the file extension. / / The file full path. / public string GetFileExtension(
8、string FileFullPath) if (File.Exists(FileFullPath) = true) FileInfo F = new FileInfo(FileFullPath); return F.Extension; else return null; / / Opens the file. / / The file full path. / public bool OpenFile(string FileFullPath) if (File.Exists(FileFullPath) = true) System.Diagnostics.Process.Start(Fil
9、eFullPath); return true; else return false; / / Gets the size of the file. / / The file full path. / public string GetFileSize(string FileFullPath) if (File.Exists(FileFullPath) = true) FileInfo F = new FileInfo(FileFullPath); long FL = F.Length; if (FL 1024 * 1024 * 1024) / KB MB GB TB return Syste
10、m.Convert.ToString(Math.Round(FL + 0.00) / (1024 * 1024 * 1024), 2) + GB; else if (FL 1024 * 1024) return System.Convert.ToString(Math.Round(FL + 0.00) / (1024 * 1024), 2) + MB; else return System.Convert.ToString(Math.Round(FL + 0.00) / 1024, 2) + KB; else return null; / / Files to stream byte. / /
11、 The file full path. / public byte FileToStreamByte(string FileFullPath) byte fileData = null; if (File.Exists(FileFullPath) = true) FileStream FS = new FileStream(FileFullPath, System.IO.FileMode.Open); fileData = new byteFS.Length; FS.Read(fileData, 0, fileData.Length); FS.Close(); return fileData
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 操作系统 课程设计 报告 文件 管理 系统
