![操作系統(tǒng)課程設(shè)計(jì)報(bào)告文件管理系統(tǒng)_第1頁](http://file2.renrendoc.com/fileroot_temp3/2021-10/28/b2e6949c-2b00-4ea9-86a8-d6da77578d82/b2e6949c-2b00-4ea9-86a8-d6da77578d821.gif)
![操作系統(tǒng)課程設(shè)計(jì)報(bào)告文件管理系統(tǒng)_第2頁](http://file2.renrendoc.com/fileroot_temp3/2021-10/28/b2e6949c-2b00-4ea9-86a8-d6da77578d82/b2e6949c-2b00-4ea9-86a8-d6da77578d822.gif)
![操作系統(tǒng)課程設(shè)計(jì)報(bào)告文件管理系統(tǒng)_第3頁](http://file2.renrendoc.com/fileroot_temp3/2021-10/28/b2e6949c-2b00-4ea9-86a8-d6da77578d82/b2e6949c-2b00-4ea9-86a8-d6da77578d823.gif)
![操作系統(tǒng)課程設(shè)計(jì)報(bào)告文件管理系統(tǒng)_第4頁](http://file2.renrendoc.com/fileroot_temp3/2021-10/28/b2e6949c-2b00-4ea9-86a8-d6da77578d82/b2e6949c-2b00-4ea9-86a8-d6da77578d824.gif)
![操作系統(tǒng)課程設(shè)計(jì)報(bào)告文件管理系統(tǒng)_第5頁](http://file2.renrendoc.com/fileroot_temp3/2021-10/28/b2e6949c-2b00-4ea9-86a8-d6da77578d82/b2e6949c-2b00-4ea9-86a8-d6da77578d825.gif)
版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡介
1、 計(jì)算機(jī)科學(xué)與技術(shù)學(xué)院課程設(shè)計(jì)報(bào)告 ( 20008 2009 學(xué)年度 第 一 學(xué)期 )課程名稱操作系統(tǒng)課程設(shè)計(jì)項(xiàng)目名稱文件管理系統(tǒng)姓名*學(xué)號*專業(yè)班級地點(diǎn)教師一、設(shè)計(jì)任務(wù)及主要技術(shù)本設(shè)計(jì)的目的是通過設(shè)計(jì)和調(diào)試一個(gè)簡單的文件系統(tǒng),通過模擬文件操作命令的執(zhí)行,來模擬文件管理,使學(xué)生對主要文件操作命令的實(shí)質(zhì)和執(zhí)行過程有比較深入的了解,掌握它們的基本實(shí)施方法。具體要求如下:設(shè)計(jì)一個(gè)支持n個(gè)用戶的文件系統(tǒng),每個(gè)用戶可擁有多個(gè)文件;采用二級或二級以上的多級文件目錄管理;對文件應(yīng)設(shè)置存取控制保護(hù)方式,如“只能執(zhí)行”、“允許讀”、“允許寫”等;系統(tǒng)的外部特征應(yīng)接近于真實(shí)系統(tǒng),可設(shè)置下述文件操作命令:建立文件、
2、打開文件、關(guān)閉文件、刪除文件、讀文件、寫文件、復(fù)制文件、查詢目錄;通過鍵盤使用該文件系統(tǒng),系統(tǒng)應(yīng)顯示操作命令的執(zhí)行結(jié)果。二、設(shè)計(jì)方案:主要模仿和實(shí)現(xiàn)windows中”我的電腦”的部分功能系統(tǒng)原理框圖:一、 實(shí)驗(yàn)源碼 :using system;using system.collections.generic;using system.text;using system.io;using system.collections;namespace filediroperate / <summary> / 與文件有關(guān)的操作類 / </summary> public class
3、 fileoperate / <summary> / deletes the file. / </summary> / <param name="filefullpath">要?jiǎng)h除的文件全路徑</param> / <returns></returns> public bool deletefile(string filefullpath) if (file.exists(filefullpath) = true) file.setattributes(filefullpath, fileattribut
4、es.normal); file.delete(filefullpath); return true; else return false; / <summary> / gets the name of the file.包括文件的擴(kuò)展名 / </summary> / <param name="filefullpath">文件的全路徑</param> / <returns></returns> public string getfilename(string filefullpath) if (file
5、.exists(filefullpath) = true) fileinfo f = new fileinfo(filefullpath); return f.name; else return null; / <summary> / gets the name of the file. / </summary> / <param name="filefullpath">文件的全路徑</param> / <param name="includeextension">是否包含文件的擴(kuò)展名</
6、param> / <returns></returns> public string getfilename(string filefullpath, bool includeextension) if (file.exists(filefullpath) = true) fileinfo f = new fileinfo(filefullpath); if (includeextension = true) return f.name; else return f.name.replace(f.extension, ""); else ret
7、urn null; / <summary> / 得到文件的大小 / </summary> / <param name="info">fileinfo</param> / <returns></returns> public string getfilesize(fileinfo info) if (info.exists = true) long fl =info.length; if (fl > 1024 * 1024 * 1024) / kb mb gb tb return system.co
8、nvert.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 retur
9、n null; / <summary> / 得到文件的后綴名 / </summary> / <param name="info">fileinfo</param> / <returns></returns> public string getfileextension(fileinfo info) if (info.exists = true) string extension=info.extension; return extension;/.substring(1); / return exten
10、sion.substring(1, extension.length - 1); else return null; / <summary> / gets the file extension. / </summary> / <param name="filefullpath">the file full path.</param> / <returns></returns> public string getfileextension(string filefullpath) if (file.exi
11、sts(filefullpath) = true) fileinfo f = new fileinfo(filefullpath); return f.extension; else return null; / <summary> / opens the file. / </summary> / <param name="filefullpath">the file full path.</param> / <returns></returns> public bool openfile(string
12、 filefullpath) if (file.exists(filefullpath) = true) system.diagnostics.process.start(filefullpath); return true; else return false; / <summary> / gets the size of the file. / </summary> / <param name="filefullpath">the file full path.</param> / <returns></
13、returns> 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 system.convert.tostring(math.round(fl + 0.00) / (1024 * 1024 * 1024), 2) + " gb"
14、; 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; / <summary> / files to stream byte. / </summary> / <param
15、 name="filefullpath">the file full path.</param> / <returns></returns> public byte filetostreambyte(string filefullpath) byte filedata = null; if (file.exists(filefullpath) = true) filestream fs = new filestream(filefullpath, system.io.filemode.open); filedata = new by
16、tefs.length; fs.read(filedata, 0, filedata.length); fs.close(); return filedata; else return null; / <summary> / bytes the stream to file. / </summary> / <param name="createfilefullpath">the create file full path.</param> / <param name="streambyte">t
17、he stream byte.</param> / <returns></returns> public bool bytestreamtofile(string createfilefullpath, byte streambyte) try if (file.exists(createfilefullpath) = true) deletefile(createfilefullpath); filestream fs; fs = file.create(createfilefullpath); fs.write(streambyte, 0, stream
18、byte.length); fs.close(); return true; catch return false; / <summary> / 序列化xml文件 / </summary> / <param name="filefullpath">the file full path.</param> / <returns></returns> public bool serializexmlfile(string filefullpath) try system.data.dataset ds = n
19、ew system.data.dataset(); ds.readxml(filefullpath); filestream fs = new filestream(filefullpath + ".tmp", filemode.openorcreate); system.runtime.serialization.formatters.binary.binaryformatter ft = new system.runtime.serialization.formatters.binary.binaryformatter(); ft.serialize(fs, ds);
20、fs.close(); deletefile(filefullpath); file.move(filefullpath + ".tmp", filefullpath); return true; catch return false; / <summary> / 反序列化xml文件 / </summary> / <param name="filefullpath">the file full path.</param> / <returns></returns> public bo
21、ol deserializexmlfile(string filefullpath) try system.data.dataset ds = new system.data.dataset(); filestream fs = new filestream(filefullpath, filemode.open); system.runtime.serialization.formatters.binary.binaryformatter ft = new system.runtime.serialization.formatters.binary.binaryformatter(); (s
22、ystem.data.dataset)ft.deserialize(fs).writexml(filefullpath + ".tmp"); fs.close(); deletefile(filefullpath); file.move(filefullpath + ".tmp", filefullpath); return true; catch return false; / <summary> / 得到文件的創(chuàng)建時(shí)間 / </summary> / <param name="info"><
23、/param> / <returns></returns> public string getfilecreatetime(fileinfo info) return info.creationtime.tostring(); / <summary> / 得到文件最后一次修改時(shí)間 / </summary> / <param name="info"></param> / <returns></returns> public string getfilelastmodifyti
24、me(fileinfo info) return info.lastwritetime.tostring(); / <summary> / 與文件夾有關(guān)的操作類 / </summary> public class diroperate public enum operateoption / <summary> / 存在刪除再創(chuàng)建 / </summary> existdelete, / <summary> / 存在直接返回 / </summary> existreturn / <summary> / 創(chuàng)建文件夾
25、/ </summary> / <param name="dirfullpath">the dir full path.</param> / <param name="diroperateoption">the dir operate option.</param> / <returns></returns> public bool createdir(string dirfullpath, operateoption diroperateoption) try if (d
26、irectory.exists(dirfullpath) = false) directory.createdirectory(dirfullpath); else if (diroperateoption = operateoption.existdelete) directory.delete(dirfullpath, true); return true; catch return false; / <summary> / 刪除文件夾 / </summary> / <param name="dirfullpath">the dir
27、full path.</param> / <returns>成功則為true 否則為false</returns> public bool deletedir(string dirfullpath) if (directory.exists(dirfullpath) = true) directory.delete(dirfullpath, true); return true; else return false; / <summary> / gets the dir files. / </summary> / <param
28、name="dirfullpath">the dir full path.</param> / <returns></returns> public string getdirfiles(string dirfullpath) string filelist = null; if (directory.exists(dirfullpath) = true) filelist = directory.getfiles(dirfullpath, "*.*", searchoption.topdirectoryonly
29、); return filelist; / <summary> / gets the dir files. / </summary> / <param name="dirfullpath">the dir full path.</param> / <param name="so">the so.</param> / <returns></returns> public string getdirfiles(string dirfullpath, searcho
30、ption so) string filelist = null; if (directory.exists(dirfullpath) = true) filelist = directory.getfiles(dirfullpath, "*.*", so); return filelist; arraylist filelist = new arraylist(); public arraylist getdirfiles(string dirfullpath, string pattern) if (directory.exists(dirfullpath) direc
31、toryinfo inf = new directoryinfo(dirfullpath); filesysteminfo infos = inf.getfilesysteminfos(); foreach (filesysteminfo info in infos) if (info is fileinfo) if(info.name.contains(pattern) filelist.add(info.fullname); else if (info.name.contains(pattern) filelist.add(info.fullname); getdirfiles(info.
32、fullname, pattern); return filelist; / <summary> / gets the dir files. / </summary> / <param name="dirfullpath">the dir full path.</param> / <param name="searchpattern">the search pattern.</param> / <returns>所有文件</returns> public st
33、ring getdirfiles(string dirfullpath, string searchpattern) string filelist = null; if (directory.exists(dirfullpath) = true) filelist = directory.getfiles(dirfullpath, searchpattern); return filelist; / <summary> / gets the dir files. / </summary> / <param name="dirfullpath"
34、>the dir full path.</param> / <param name="searchpattern">the search pattern.</param> / <param name="so">the so.</param> / <returns>與當(dāng)前條件匹配的所有文件和文件夾</returns> public string getdirfiles(string dirfullpath, string searchpattern, searchop
35、tion so) string filelist = null; if (directory.exists(dirfullpath) = true) filelist = directory.getfiles(dirfullpath, searchpattern, so); return filelist; / <summary> / 得到文件的創(chuàng)建時(shí)間 / </summary> / <param name="filefullpath">文件的全路徑</param> / <returns>文件的創(chuàng)建時(shí)間</r
36、eturns> public string getfilecreatetime(string filefullpath) fileinfo info = new fileinfo(filefullpath); if (info.exists) return info.creationtime.tostring(); else return "" / <summary> / 得到文件最后一次修改的時(shí)間 / </summary> / <param name="filefullpath">文件的全路徑</para
37、m> / <returns>文件的最后修改時(shí)間</returns> public string getfilelastmodifytime(string filefullpath) if(file.exists(filefullpath) return new fileinfo(filefullpath).lastwritetime.tostring(); else return "" / <summary> / 得到當(dāng)前目錄下的子目錄或文件 / </summary> / <param name="fil
38、efullpath">目錄或文件的完整路徑</param> / <returns>當(dāng)前目錄的所有子目錄和子文件</returns> public filesysteminfo getfilesysteminfo(string filefullpath) if(directory.exists(filefullpath) directoryinfo info=new directoryinfo(filefullpath); return info.getfilesysteminfos(); else return null; / <sum
39、mary> / 得到文件的創(chuàng)建時(shí)間 / </summary> / <param name="info"></param> / <returns></returns> public string getdircreationtime(directoryinfo info) return info.creationtime.tostring(); / <summary> / 得到文件最后一次修改的時(shí)間 / </summary> / <param name="info&quo
40、t;></param> / <returns></returns> public string getdirlastmodifytime(directoryinfo info) return info.lastwritetime.tostring(); / <summary> / 保存文件夾的大小 / </summary> private long length = 0; / <summary> / 獲得文件夾的大小 / </summary> / <param name="info&quo
41、t;>文件夾實(shí)例</param> / <returns>文件夾大小</returns> public long getdirsize(directoryinfo info) if (info.exists) filesysteminfo infos = info.getfilesysteminfos(); foreach (filesysteminfo inf in infos)/循環(huán)每一個(gè)目錄里的每一個(gè)文件得到總的文件夾的大小 if (inf is directoryinfo) length = +getdirsize(directoryinfo)inf); else length+=(fileinfo)inf).length; /return length; return length; else return 0; / <summary> / 循環(huán)得到文件夾的大小 / &l
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 2025年度預(yù)制構(gòu)件瓦工施工與裝配合同范本
- 2025年度高校教師國際交流與合作合同協(xié)議
- 2025年度黃金抵押貸款與農(nóng)業(yè)現(xiàn)代化項(xiàng)目合同范本
- 2025年度新型綠色建筑節(jié)能改造工程合同簽訂細(xì)則
- 2025年度房地產(chǎn)居間服務(wù)合同糾紛起訴狀范本
- 2025年度工業(yè)原材料供應(yīng)與采購合同范本
- 2025年度化妝品品牌線上線下融合營銷合同范本
- 2025年度市場分析顧問兼職聘用合同書
- 2025年度智能交通系統(tǒng)合資研發(fā)合同
- 2025年度綠色有機(jī)肥料大宗采購合同
- Starter Unit 1 Hello!說課稿2024-2025學(xué)年人教版英語七年級上冊
- 2025年初中語文:春晚觀后感三篇
- Unit 7 第3課時(shí) Section A (Grammar Focus -4c)(導(dǎo)學(xué)案)-【上好課】2022-2023學(xué)年八年級英語下冊同步備課系列(人教新目標(biāo)Go For It!)
- 《教育強(qiáng)國建設(shè)規(guī)劃綱要(2024-2035年)》解讀講座
- 《基于新課程標(biāo)準(zhǔn)的初中數(shù)學(xué)課堂教學(xué)評價(jià)研究》
- 省級產(chǎn)業(yè)園區(qū)基礎(chǔ)設(shè)施項(xiàng)目可行性研究報(bào)告
- 預(yù)算績效評價(jià)管理機(jī)構(gòu)入圍投標(biāo)文件(技術(shù)方案)
- 2019北師大版高中英語選擇性必修四單詞表
- 園藝產(chǎn)品的品質(zhì)講義
- 鋼筋混凝土框架結(jié)構(gòu)工程監(jiān)理的質(zhì)量控制
- 桃花節(jié)活動(dòng)方案
評論
0/150
提交評論