外贸公司手机网站怎么用文件传输协议登录网站

张小明 2026/1/19 22:02:08
外贸公司手机网站,怎么用文件传输协议登录网站,广告艺术设计学的是什么,节省空间的装修设计操作文件和文件夹是程序开发中常用#xff0c;无论是C/S和B/S都会存在操作文件的需求#xff0c;比如上传新闻图片按日期创建文件夹#xff0c;用文本文件存储用户信息等。下面介绍28种文件操作的方法#xff0c;希望对大家的开发有所帮助1.创建文件夹//using System.IO;Di…操作文件和文件夹是程序开发中常用无论是C/S和B/S都会存在操作文件的需求比如上传新闻图片按日期创建文件夹用文本文件存储用户信息等。下面介绍28种文件操作的方法希望对大家的开发有所帮助1.创建文件夹//using System.IO;Directory.CreateDirectory(path);2.创建文件//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()){ //写入数据错误return; } }//数据流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,path2\file.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;你还有哪些文件操作的方法欢迎留言。版权声明本文来源于网友收集或网友提供仅供学习交流之用如果有侵权请转告版主或者留言本公众号立即删除。- EOF -技术群添加小编微信dotnet999公众号dotnet讲堂
版权声明:本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若内容造成侵权/违法违规/事实不符,请联系邮箱:809451989@qq.com进行投诉反馈,一经查实,立即删除!

网上做视频赚钱的网站wordpress 媒体库加载不了图片

企业网络设计案例分析 在全球范围内,许多组织都在考虑采用 Windows 2000 系统,规划未来的 Active Directory,或者已经实施了相关系统。下面以 Kings Vineyards 公司为例,详细介绍企业网络设计的过程。 1. 案例概述 Kings Vineyards 是一家致力于葡萄酒生产和分销的公司,…

张小明 2026/1/17 17:37:38 网站建设

提交网站广州市企业网站建设平台

品牌故事编写:传递核心价值观 在信息爆炸的时代,知识不再稀缺,真正稀缺的是从海量文档中快速提取关键信息的能力。无论是工程师翻找技术手册、律师查阅合同条款,还是HR解答员工关于年假政策的提问,传统“搜索-阅读-总结…

张小明 2026/1/17 17:37:39 网站建设

专门做美食的网站6温岭市建设局网站审批公示

医疗安全数字化的落地挑战:从WHO核查表到智能系统在手术室里,时间就是生命。可就在这样一个分秒必争的环境中,医护人员每天仍要花几分钟时间停下操作,逐项核对一份纸质清单——手术安全核查表。这看似简单的流程,背后承…

张小明 2026/1/17 17:37:41 网站建设

长沙经开区建设局网站国外一个做ppt的网站

快速体验 打开 InsCode(快马)平台 https://www.inscode.net输入框内输入如下内容: 生成一个交互式JDK 17安装向导程序,要求:1.图形化界面 2.分步骤引导用户完成下载和安装 3.实时显示操作截图和说明 4.内置常见问题解答 5.安装完成后弹出验证…

张小明 2026/1/17 17:37:42 网站建设

网站推广渠道有哪些优秀的手机网站案例

精通Windows虚拟磁盘:3个核心技能打造高效存储管理方案 【免费下载链接】ImDisk ImDisk Virtual Disk Driver 项目地址: https://gitcode.com/gh_mirrors/im/ImDisk 还在为频繁切换镜像文件而烦恼?或者希望为系统性能注入一剂强心针?I…

张小明 2026/1/17 17:37:42 网站建设

梅州市建设培训中心网站wordpress邮箱插件漏洞

快速体验 打开 InsCode(快马)平台 https://www.inscode.net输入框内输入如下内容: 创建一个工具,能够自动检测JSON格式错误,特别是类似expecting value: line 1 column 1 (char 0)的常见问题。工具应能分析输入的JSON字符串,识别…

张小明 2026/1/17 17:37:44 网站建设