97色伦色在线综合视频,无玛专区,18videosex性欧美黑色,日韩黄色电影免费在线观看,国产精品伦理一区二区三区,在线视频欧美日韩,亚洲欧美在线中文字幕不卡

初中生可做兼職的網(wǎng)站百度云盤資源

鶴壁市浩天電氣有限公司 2026/01/24 10:43:36
初中生可做兼職的網(wǎng)站,百度云盤資源,無錫大型網(wǎng)站設計公司,學室內設計要多久能學會操作文件和文件夾是程序開發(fā)中常用#xff0c;無論是C/S和B/S都會存在操作文件的需求#xff0c;比如上傳新聞圖片按日期創(chuàng)建文件夾#xff0c;用文本文件存儲用戶信息等。下面介紹28種文件操作的方法#xff0c;希望對大家的開發(fā)有所幫助1.創(chuàng)建文件夾//using System.IO;Di…操作文件和文件夾是程序開發(fā)中常用無論是C/S和B/S都會存在操作文件的需求比如上傳新聞圖片按日期創(chuàng)建文件夾用文本文件存儲用戶信息等。下面介紹28種文件操作的方法希望對大家的開發(fā)有所幫助1.創(chuàng)建文件夾//using System.IO;Directory.CreateDirectory(path);2.創(chuàng)建文件//using System.IO;File.Create(path);3.刪除文件//using System.IO;File.Delete(path);4.刪除文件夾//using System.IO;Directory.Delete(path);5.刪除一個目錄下所有的文件夾//using System.IO;foreach (string dirStr in Directory.GetDirectories(path)){ DirectoryInfo dir new DirectoryInfo(dirStr); ArrayList foldersnew ArrayList(); FileSystemInfo[] fileArr dir.GetFileSystemInfos();for (int i 0; i folders.Count; i) { FileInfo f folders[i] as FileInfo;if (f null) { DirectoryInfo d folders[i] as DirectoryInfo; d.Delete(); } }}6.清空文件夾//using System.IO;Directory.Delete(path,true);Directory.CreateDirectory(path);7.讀取文件//using System.IO;StreamReader s File.OpenText(path1);string str2 null;while ((str2 s.ReadLine()) ! null){ }s.Close();8.寫入文件//using System.IO;FileInfo f new FileInfo(str);StreamWriter w f.CreateText();w.WriteLine(ReadOnlySpan);w.Close();9.寫入隨機文件//using System.IO;byte[] dataArray new byte[100000];//new Random().NextBytes(dataArray);using(FileStream FileStream new FileStream(path, FileMode.Create)){// Write the data to the file, byte by byte.for(int i 0; i dataArray.Length; i){ FileStream.WriteByte(dataArray[i]); }// Set the stream position to the beginning of the file. FileStream.Seek(0, SeekOrigin.Begin);// Read and verify the data.for(int i 0; i FileStream.Length; i){if(dataArray[i] ! FileStream.ReadByte()){ //寫入數(shù)據(jù)錯誤return; } }//數(shù)據(jù)流FileStream.Name已驗證}10.讀取文件屬性//using System.IO;FileInfo f new FileInfo(path);//f.CreationTime,f.FullNameif((f.Attributes FileAttributes.ReadOnly) ! 0){ path2}else{ path3}11.寫入屬性//using System.IO;FileInfo f new FileInfo(path);//設置只讀f.Attributes myFile.Attributes | FileAttributes.ReadOnly;//設置可寫f.Attributes myFile.Attributes ~FileAttributes.ReadOnly; 12.枚舉一個文件夾中的所有文件夾//using System.IO;foreach (string path2 in Directory.GetDirectories(path)){ path3}13.復制文件夾string path (path2.LastIndexOf() path2.Length - 1) ? path2 : path2;string parent Path.GetDirectoryName(path);Directory.CreateDirectory(path Path.GetFileName(path));DirectoryInfo dir new DirectoryInfo((path.LastIndexOf() path.Length - 1) ? path1 : path1 );FileSystemInfo[] fileArr dir.GetFileSystemInfos();QueueFileSystemInfo Folders new QueueFileSystemInfo(dir.GetFileSystemInfos());while (Folders.Count0){ FileSystemInfo tmp Folders.Dequeue(); FileInfo f tmp as FileInfo;if (f null) { DirectoryInfo d tmp as DirectoryInfo; Directory.CreateDirectory(d.FullName.Replace((parent.LastIndexOf() parent.Length - 1) ? parent : parent , path));foreach (FileSystemInfo fi in d.GetFileSystemInfos()) { Folders.Enqueue(fi); } }else { f.CopyTo(f.FullName.Replace(parent, path)); }}14.復制目錄下所有的文件夾到另一個文件夾下DirectoryInfo d new DirectoryInfo(path);foreach (DirectoryInfo dirs in d.GetDirectories()){ QueueFileSystemInfo al new QueueFileSystemInfo(dirs.GetFileSystemInfos());while (al.Count 0) { FileSystemInfo temp al.Dequeue(); FileInfo file temp as FileInfo;if (file null) { DirectoryInfo directory temp as DirectoryInfo; Directory.CreateDirectory(path directory.Name);foreach (FileSystemInfo fsi in directory.GetFileSystemInfos()) al.Enqueue(fsi); }else File.Copy(file.FullName, path file.Name); }}15.移動文件夾string filename Path.GetFileName(path); string path(path2.LastIndexOf() path2.Length - 1) ? path2 : path2 ;if (Path.GetPathRoot(path) Path.GetPathRoot(path2)) Directory.Move(path, path filename);else { string parent Path.GetDirectoryName(path); Directory.CreateDirectory(path Path.GetFileName(path1)); DirectoryInfo dir new DirectoryInfo((path.LastIndexOf() path1.Length - 1) ? path1 : path1 ); FileSystemInfo[] fileArr dir.GetFileSystemInfos(); QueueFileSystemInfo Folders new QueueFileSystemInfo(dir.GetFileSystemInfos());while (Folders.Count 0) { FileSystemInfo tmp Folders.Dequeue(); FileInfo f tmp as FileInfo;if (f null) { DirectoryInfo d tmp as DirectoryInfo; DirectoryInfo dpath new DirectoryInfo(d.FullName.Replace((parent.LastIndexOf() parent.Length - 1) ? parent : parent , path)); dpath.Create();foreach (FileSystemInfo fi in d.GetFileSystemInfos()) { Folders.Enqueue(fi); } }else { f.MoveTo(f.FullName.Replace(parent, path)); } } Directory.Delete(path, true); }16.移動目錄下所有的文件夾到另一個目錄下string filename Path.GetFileName(path);if (Path.GetPathRoot(path) Path.GetPathRoot(path2))foreach (string dir in Directory.GetDirectories(path1)) Directory.Move(dir, Path.Combine(path2,filename));else {foreach (string dir2 in Directory.GetDirectories(path1)) { string parent Path.GetDirectoryName(dir2); Directory.CreateDirectory(Path.Combine(path2, Path.GetFileName(dir2))); string dir (dir2.LastIndexOf() dir2.Length - 1) ? dir2 : dir2 ; DirectoryInfo dirdir new DirectoryInfo(dir); FileSystemInfo[] fileArr dirdir.GetFileSystemInfos(); QueueFileSystemInfo Folders new QueueFileSystemInfo(dirdir.GetFileSystemInfos());while (Folders.Count 0) { FileSystemInfo tmp Folders.Dequeue(); FileInfo f tmp as FileInfo;if (f null) { DirectoryInfo d tmp as DirectoryInfo; DirectoryInfo dpath new DirectoryInfo(d.FullName.Replace((parent.LastIndexOf() parent.Length - 1) ? parent : parent , path2)); dpath.Create();foreach (FileSystemInfo fi in d.GetFileSystemInfos()) { Folders.Enqueue(fi); } }else { f.MoveTo(f.FullName.Replace(parent, path2)); } } dirdir.Delete(true); } }18.復制文件//using System.IO;File.Copy(path1,path2);19.復制一個文件夾下所有的文件到另一個目錄//using System.IO;foreach (string fileStr in Directory.GetFiles(path1)) File.Copy((path1.LastIndexOf() path1.Length - 1) ? path1 Path.GetFileName(fileStr): path1 Path.GetFileName(fileStr),(path2.LastIndexOf(\) path2.Length - 1) ? path2 Path.GetFileName(fileStr): path2 Path.GetFileName(fileStr));20.提取擴展名//using System.IO;string path2Path.GetExtension(path1);21.提取文件名//using System.IO;string path2Path.GetFileName(path1);22.提取文件路徑//using System.IO;string path2Path.GetDirectoryName(path1);23.替換擴展名//using System.IO;File.ChangeExtension(path1,path2);24.追加路徑//using System.IO;string path3Path.Combine(path1,path2);25.移動文件//using System.IO;File.Move(path1,path2file.getname(path1));26.移動一個文件夾下所有文件到另一個目錄foreach (string fileStr in Directory.GetFiles(path1)) File.Move((path1.LastIndexOf() path1.Length - 1) ? path1 Path.GetFileName(fileStr): path1 Path.GetFileName(fileStr),(path2.LastIndexOf(\) path2.Length - 1) ? path2 Path.GetFileName(fileStr): path2 Path.GetFileName(fileStr));27.指定目錄下搜索文件string fileNamepath1;string dirNamepath2; DirectoryInfo dircnew DirectoryInfo(dirName);foreach(FileInfo file in dirc.GetFiles()) {if(file.Name.IndexOf(fileName)-1)return file.FullName; }foreach(DirectoryInfo dir in dirc.GetDirectories()) { return GetFile(fileName,dir.FullName); }return找不到指定的文件; }28.獲得當前路徑string pathEnvironment.CurrentDirectory;你還有哪些文件操作的方法歡迎留言。版權聲明本文來源于網(wǎng)友收集或網(wǎng)友提供僅供學習交流之用如果有侵權請轉告版主或者留言本公眾號立即刪除。- EOF -技術群添加小編微信dotnet999公眾號dotnet講堂
版權聲明: 本文來自互聯(lián)網(wǎng)用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。如若內容造成侵權/違法違規(guī)/事實不符,請聯(lián)系我們進行投訴反饋,一經(jīng)查實,立即刪除!

客戶做網(wǎng)站一定報價怎么辦貝殼房源網(wǎng)

客戶做網(wǎng)站一定報價怎么辦,貝殼房源網(wǎng),做網(wǎng)站的動態(tài)圖片,崇左網(wǎng)頁設計文檔自動化革命#xff1a;Document-Generator打造開源項目專業(yè)文檔 【免費下載鏈接】obs-vst Use VST

2026/01/22 21:16:02

大瀝網(wǎng)站制作網(wǎng)站建設銷售培訓

大瀝網(wǎng)站制作,網(wǎng)站建設銷售培訓,建筑導航網(wǎng)站,做圖素材網(wǎng)站 千paperxie-免費查重復率aigc檢測/開題報告/畢業(yè)論文/智能排版/文獻綜述/aippt https://www.paperxie

2026/01/22 21:37:02

如何做自己網(wǎng)站的seo兒童影樓網(wǎng)站設計

如何做自己網(wǎng)站的seo,兒童影樓網(wǎng)站設計,什么網(wǎng)站做視頻,鄭州網(wǎng)站建設制作費用一、題目描述二、算法原理思路#xff1a;歸并排序#xff08;降序#xff09; 雙指針如果#xff1a;nums [

2026/01/23 01:33:01

鄭州做商城網(wǎng)站做一家拍賣網(wǎng)站需要什么資質

鄭州做商城網(wǎng)站,做一家拍賣網(wǎng)站需要什么資質,公司注冊網(wǎng)站模板,免費團購網(wǎng)站模板語音合成中的連讀與弱讀現(xiàn)象模擬#xff1a;GPT-SoVITS提升自然度的秘密 在虛擬主播流暢播報新聞、有聲書娓娓道來故

2026/01/21 20:14:02

人才招聘網(wǎng)站開發(fā) 源代碼騰訊網(wǎng)站建設

人才招聘網(wǎng)站開發(fā) 源代碼,騰訊網(wǎng)站建設,服裝設計網(wǎng)站知乎,企業(yè)網(wǎng)站營銷實現(xiàn)方式第一章#xff1a;工業(yè)質檢 Agent 的精度挑戰(zhàn)本質 在現(xiàn)代智能制造體系中#xff0c;工業(yè)質檢 Agent 承擔著對

2026/01/21 16:56:01

中醫(yī)醫(yī)院網(wǎng)站建設需求建筑模板哪種好

中醫(yī)醫(yī)院網(wǎng)站建設需求,建筑模板哪種好,輿情監(jiān)測軟件有哪些,網(wǎng)站怎么開通微信支付還在為錯過Epic Games商店的每周特惠游戲而煩惱嗎#xff1f;現(xiàn)在有一款名為epicgames-freebies-

2026/01/21 19:59:01