系统特殊目录路径

  1. //取得特殊文件夹的绝对路径
  2. //桌面
  3. Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
  4. //收藏夹
  5. Environment.GetFolderPath(Environment.SpecialFolder.Favorites);
  6. //我的文档
  7. Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
  8. //最近使用的文档
  9. Environment.GetFolderPath(Environment.SpecialFolder.Recent);

文件操作

  1. void CheckFileExists()
  2. {
  3. //通过函数File.Exists方法判断文件是否存在
  4. //string fileName = @"C:\Dell\demo.txt";
  5. //if (File.Exists(fileName))
  6. //{
  7. // Console.WriteLine("File {0} exists.", fileName);
  8. //}
  9. string fileName = @"C:\Dell\demo.txt";
  10. if (File.Exists(fileName))
  11. this.tbInfo.AppendText(fileName + "存在\r\n"); else
  12. this.tbInfo.AppendText(fileName + "不存在\r\n");
  13. }
  14. void GetFileInfo()
  15. {
  16. //通过FileInfo取得文件属性
  17. string fileName = this.tbFile.Text;
  18. FileInfo info = new FileInfo(fileName);
  19. // 判断文件是否存在
  20. this.tbInfo.AppendText("文件是否存在:" + info.Exists.ToString() + "\r\n");
  21. // 获取文件名
  22. this.tbInfo.AppendText("文件名:" + info.Name + "\r\n");
  23. // 获取文件扩展名
  24. this.tbInfo.AppendText("扩展名:" + info.Extension + "\r\n");
  25. // 获取文件躲在文件夹
  26. this.tbInfo.AppendText("所在文件夹:" + info.Directory.Name + "\r\n");
  27. // 获取文件长度
  28. this.tbInfo.AppendText("文件长度:" + info.Length + "\r\n");
  29. // 获取或设置文件是否只读
  30. this.tbInfo.AppendText("是否只读:" + info.IsReadOnly + "\r\n");
  31. // 获取或设置文件创建时间
  32. this.tbInfo.AppendText("创建时间:" + info.CreationTime + "\r\n");
  33. // 获取或设置文件最后一次访问时间
  34. this.tbInfo.AppendText("最后一次访问时间:" + info.LastAccessTime + "\r\n");
  35. // 获取或设置文件最后一次写入时间
  36. this.tbInfo.AppendText("最后一次写入时间:" + info.LastWriteTime + "\r\n");
  37. }
  38. void CopyFile()
  39. {
  40. // 复制文件
  41. // 原文件
  42. string sourceFileName = @"C:\Users\Dell\Desktop\timer.png";
  43. // 新文件
  44. string destFileName = @"e:\timer.png";
  45. File.Copy(sourceFileName, destFileName);
  46. }
  47. void MoveFile()
  48. {
  49. // 移动文件,可以跨卷标移动
  50. // 文件移动后原文件被删除
  51. string sourceFileName = @"C:\Users\Dell\Desktop\timer.png";
  52. string destFileName = @"e:\timer.png";
  53. File.Move(sourceFileName, destFileName);
  54. }
  55. void DeleteFile()
  56. {
  57. //删除指定文件
  58. string fileName = @"C:\Dell\demo.txt";
  59. // 删除前需检查文件是否存在
  60. if (File.Exists(fileName))
  61. File.Delete(fileName);
  62. }
  63. void PickFile()
  64. {
  65. //从工具箱拖入OpenFileDialog控件命名为ofd,或者直接定义
  66. OpenFileDialog ofd = new OpenFileDialog();
  67. // 当所选文件不存在时给出警告提示
  68. ofd.CheckFileExists = true;
  69. // 是否添加默认文件扩展名
  70. ofd.AddExtension = true;
  71. // 设置默认扩展文件名
  72. ofd.DefaultExt = ".txt";
  73. // 设置文件类型筛选规则,
  74. // 组与组之间用“|”分隔,每组中文件类型与扩展名用“|”分割,多个文件类型用“;”分隔
  75. ofd.Filter = "文本文件|*.txt|图片文件|*.png;*gif;*.jpg;*.jpeg;*.bmp";
  76. // 设置是否支持多选
  77. ofd.Multiselect = true;
  78. // 设置对话框标题
  79. ofd.Title = "选择文件:";
  80. if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
  81. {
  82. this.tbFile.Text = ofd.FileName;
  83. // 依次列出多选的文件名称
  84. foreach (string fname in ofd.FileNames)
  85. {
  86. this.tbInfo.AppendText(fname + "\r\n");
  87. }
  88. }
  89. }
  90. void RenameFile()
  91. {
  92. // 使用VB方法,重命名文件
  93. Computer myPC = new Computer();
  94. string sourceFileName = @"C:\Users\Dai\Desktop\截图\timer.png";
  95. string newFileName = @"timer12.png";
  96. //必须是名称,而不是绝对路径
  97. myPC.FileSystem.RenameFile(sourceFileName, newFileName);
  98. myPC = null;
  99. }

文件夹操作

  1. #region 文件夹操作
  2. /// <summary>
  3. /// 选择路径
  4. /// </summary>
  5. /// <param name="sender"></param>
  6. /// <param name="e"></param>
  7. private void btnOpenDir_Click(object sender, EventArgs e)
  8. {
  9. // 从工具箱拖入一个FolderBrowserDialog,命名为fbd。除了拖入,还可直接定义
  10. FolderBrowserDialog fbd = new FolderBrowserDialog();
  11. // 设置文件夹选择框提示文本
  12. fbd.Description = "请选择一个文件夹:";
  13. // 设置默认位置为桌面
  14. fbd.RootFolder = Environment.SpecialFolder.DesktopDirectory;
  15. // 设置是否显示“新建文件夹”按钮
  16. fbd.ShowNewFolderButton = false;
  17. // 设置默认选中的文件夹为本地目录
  18. fbd.SelectedPath = @"e:\";
  19. // 设置默认选中的文件夹为网络路径
  20. //this.fbd.SelectedPath = @"\\192.168.1.1\";
  21. // 显示对话框,并返回已选中的文件夹
  22. if (fbd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
  23. {
  24. this.tbDir.Text = fbd.SelectedPath;
  25. }
  26. }
  27. /// <summary>
  28. /// 文件夹属性
  29. /// </summary>
  30. /// <param name="sender"></param>
  31. /// <param name="e"></param>
  32. private void btnGetDirInfo_Click(object sender, EventArgs e)
  33. {
  34. string dirName = this.tbDir.Text;
  35. if (string.IsNullOrEmpty(dirName))
  36. {
  37. this.tbInfo.AppendText("文件夹不能空\r\n");
  38. return;
  39. }
  40. // 检查文件夹是否存在
  41. if (Directory.Exists(dirName))
  42. {
  43. // 根据路径获得文件夹属性
  44. DirectoryInfo info = new DirectoryInfo(dirName);
  45. this.tbInfo.AppendText(string.Format("完整路径:{0}\r\n", info.FullName));
  46. this.tbInfo.AppendText(string.Format("获取目录的根:{0}\r\n", info.Root));
  47. this.tbInfo.AppendText(string.Format("获取目录的父目录:{0}\r\n", info.Parent));
  48. this.tbInfo.AppendText(string.Format("创建时间:{0}\r\n", info.CreationTime));
  49. this.tbInfo.AppendText(string.Format("最后一次访问时间:{0}\r\n", info.LastAccessTime));
  50. this.tbInfo.AppendText(string.Format("最后一次写入时间:{0}\r\n", info.LastWriteTime));
  51. } else
  52. {
  53. this.tbInfo.AppendText(string.Format("文件夹不存在{0}\r\n", dirName));
  54. }
  55. }
  56. /// <summary>
  57. /// 文件夹权限
  58. /// </summary>
  59. /// <param name="sender"></param>
  60. /// <param name="e"></param>
  61. private void btnGetDirSec_Click(object sender, EventArgs e)
  62. {
  63. //取得文件夹的访问权限
  64. string dirName = this.tbDir.Text;
  65. if (string.IsNullOrEmpty(dirName))
  66. {
  67. this.tbInfo.AppendText("文件夹不能空\r\n");
  68. return;
  69. }
  70. DirectoryInfo dirInfo = new DirectoryInfo(dirName);
  71. // 需引用命名空间System.Security.AccessControl;
  72. // 取得访问控制列表ACL信息
  73. DirectorySecurity sec = dirInfo.GetAccessControl(AccessControlSections.Access);
  74. foreach (FileSystemAccessRule rule in
  75. sec.GetAccessRules(true, true, typeof(System.Security.Principal.NTAccount)))
  76. {
  77. // 文件夹名称
  78. tbInfo.AppendText(dirName + "\t");
  79. // 取得Windows账号或sid
  80. tbInfo.AppendText(rule.IdentityReference.Value + "\t");
  81. // 取得文件夹权限
  82. tbInfo.AppendText(rule.FileSystemRights.ToString() + "\r\n");
  83. }
  84. }
  85. /// <summary>
  86. /// 遍历子文件
  87. /// </summary>
  88. /// <param name="sender"></param>
  89. /// <param name="e"></param>
  90. private void btnGetDirFiles_Click(object sender, EventArgs e)
  91. {
  92. string dirName = this.tbDir.Text;
  93. if (string.IsNullOrEmpty(dirName))
  94. {
  95. this.tbInfo.AppendText("文件夹不能空\r\n");
  96. return;
  97. }
  98. //遍历文件夹中的文件
  99. DirectoryInfo info = new DirectoryInfo(dirName);
  100. foreach (FileInfo fInfo in info.GetFiles())
  101. {
  102. this.tbInfo.AppendText(fInfo.FullName + "\r\n");
  103. }
  104. }
  105. /// <summary>
  106. /// 遍历子文件夹
  107. /// </summary>
  108. /// <param name="sender"></param>
  109. /// <param name="e"></param>
  110. private void btnGetSubDir_Click(object sender, EventArgs e)
  111. {
  112. string dirName = this.tbDir.Text;
  113. if (string.IsNullOrEmpty(dirName))
  114. {
  115. this.tbInfo.AppendText("文件夹不能空\r\n");
  116. return;
  117. }
  118. //遍历文件夹中的子文件夹
  119. DirectoryInfo info = new DirectoryInfo(dirName);
  120. foreach (DirectoryInfo dInfo in info.GetDirectories())
  121. {
  122. this.tbInfo.AppendText(dInfo.FullName + "\r\n");
  123. }
  124. }
  125. /// <summary>
  126. /// 遍历全部子文件夹
  127. /// </summary>
  128. /// <param name="sender"></param>
  129. /// <param name="e"></param>
  130. private void btnGetAllSubDir_Click(object sender, EventArgs e)
  131. {
  132. string dirName = this.tbDir.Text;
  133. if (string.IsNullOrEmpty(dirName))
  134. {
  135. this.tbInfo.AppendText("文件夹不能空\r\n");
  136. return;
  137. }
  138. //使用递归方法遍历文件夹中所有的子文件夹
  139. DirectoryInfo info = new DirectoryInfo(dirName);
  140. foreach (DirectoryInfo dInfo in info.GetDirectories())
  141. {
  142. //ReadDirs(dInfo.FullName);
  143. ReadDirs(dInfo.FullName,);
  144. this.tbInfo.AppendText(dInfo.FullName + "\r\n");
  145. }
  146. }
  147. private void ReadDirs(string dirName)
  148. {
  149. // 递归读取子文件夹
  150. DirectoryInfo info = new DirectoryInfo(dirName);
  151. foreach (DirectoryInfo dInfo in info.GetDirectories())
  152. {
  153. ReadDirs(dInfo.FullName);
  154. this.tbInfo.AppendText(dInfo.FullName + "\r\n");
  155. }
  156. }
  157. private void ReadDirs(string dirName, int level)
  158. {
  159. // 记录文件夹读取深度
  160. level++;
  161. // 当遍历深度小于设定值时才继续读取
  162. if (level < totalLevel)
  163. {
  164. DirectoryInfo info = new DirectoryInfo(dirName);
  165. #region 显示文件信息
  166. foreach (FileInfo fInfo in info.GetFiles())
  167. {
  168. this.tbInfo.AppendText(fInfo.FullName + "\r\n");
  169. }
  170. #endregion
  171. #region 显示子文件夹
  172. foreach (DirectoryInfo dInfo in info.GetDirectories())
  173. {
  174. ReadDirs(dInfo.FullName, level);
  175. this.tbInfo.AppendText(dInfo.FullName + "\r\n");
  176. }
  177. #endregion
  178. }
  179. }
  180. /// <summary>
  181. /// 删除文件夹
  182. /// </summary>
  183. /// <param name="sender"></param>
  184. /// <param name="e"></param>
  185. private void btnDeleteDir_Click(object sender, EventArgs e)
  186. {
  187. string dirName = this.tbDir.Text;
  188. if (string.IsNullOrEmpty(dirName))
  189. {
  190. this.tbInfo.AppendText("文件夹不能空\r\n");
  191. return;
  192. }
  193. if (Directory.Exists(dirName))
  194. {
  195. if(MessageBox.Show("您确定要删除指定文件夹吗?","确认框",
  196. MessageBoxButtons.YesNo,MessageBoxIcon.Question)
  197. == System.Windows.Forms.DialogResult.Yes)
  198. {
  199. Directory.Delete(dirName);
  200. }
  201. }
  202. }
  203. /// <summary>
  204. /// 移动文件夹
  205. /// </summary>
  206. /// <param name="sender"></param>
  207. /// <param name="e"></param>
  208. private void btnMoveDir_Click(object sender, EventArgs e)
  209. {
  210. string dirName = this.tbDir.Text;
  211. if (string.IsNullOrEmpty(dirName))
  212. {
  213. this.tbInfo.AppendText("文件夹不能空\r\n");
  214. return;
  215. }
  216. if (Directory.Exists(dirName))
  217. {
  218. if (MessageBox.Show("您确定要移动文件夹吗?", "确认框",
  219. MessageBoxButtons.YesNo, MessageBoxIcon.Question)
  220. == System.Windows.Forms.DialogResult.Yes)
  221. {
  222. //源路径和目标路径必须具有相同的根。移动操作在卷之间无效
  223. Directory.Move(dirName, @"C:\Users\Dai\Desktop\截图222");
  224. }
  225. }
  226. }
  227. /// <summary>
  228. /// 创建文件夹
  229. /// </summary>
  230. /// <param name="sender"></param>
  231. /// <param name="e"></param>
  232. private void btnCreateDir_Click(object sender, EventArgs e)
  233. {
  234. // appPath = System.Windows.Forms.Application.StartupPath + "\\";
  235. string dirName = appPath + DateTime.Now.ToString("yyyyMMddHHmmss");
  236. Directory.CreateDirectory(dirName);
  237. this.tbInfo.AppendText(string.Format("当前工作目录:{0}\r\n", Directory.GetCurrentDirectory()));
  238. Directory.SetCurrentDirectory(@"c:\");
  239. Directory.CreateDirectory(DateTime.Now.ToString("yyyyMMddHHmmss"));
  240. this.tbInfo.AppendText(string.Format("已创建文件夹{0}\r\n", dirName));
  241. }
  242. /// <summary>
  243. /// 特殊文件夹路径
  244. /// </summary>
  245. /// <param name="sender"></param>
  246. /// <param name="e"></param>
  247. private void btnFolderPath_Click(object sender, EventArgs e)
  248. {
  249. //取得特殊文件夹的绝对路径
  250. this.tbInfo.AppendText(string.Format("特殊文件夹路径\r\n桌面:{0}\r\n", Environment.GetFolderPath(Environment.SpecialFolder.Desktop)));
  251. this.tbInfo.AppendText(string.Format("收藏夹:{0}\r\n", Environment.GetFolderPath(Environment.SpecialFolder.Favorites)));
  252. this.tbInfo.AppendText(string.Format("我的文档:{0}\r\n", Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)));
  253. this.tbInfo.AppendText(string.Format("最近使用的文档:{0}\r\n", Environment.GetFolderPath(Environment.SpecialFolder.Recent)));
  254. //取得特殊文件夹的绝对路径
  255. //桌面
  256. Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
  257. //收藏夹
  258. Environment.GetFolderPath(Environment.SpecialFolder.Favorites);
  259. //我的文档
  260. Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
  261. //最近使用的文档
  262. Environment.GetFolderPath(Environment.SpecialFolder.Recent);
  263. }
  264. /// <summary>
  265. /// 重命名
  266. /// </summary>
  267. void RenameDirectory()
  268. {
  269. // 重命名文件夹
  270. Computer myPC = new Computer();
  271. string sourceDirName = @"C:\Users\Dell\Desktop\截";
  272. string newDirName = @"截图";
  273. //必须是名称,而不是绝对路径
  274. myPC.FileSystem.RenameDirectory(sourceDirName, newDirName);
  275. myPC = null;
  276. }
  277. private void btnRenameDir_Click(object sender, EventArgs e)
  278. {
  279. RenameDirectory();
  280. }

文件读写

读取文件

FileStream

  1. try
  2. {
  3. // 以只读模式打开文本文件
  4. using (FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read))
  5. {
  6. byte[] bytes = new byte[fs.Length];
  7. int numBytesToRead = (int)fs.Length;
  8. int numBytesRead = ;
  9. while (numBytesToRead > )
  10. {
  11. int n = fs.Read(bytes, numBytesRead, numBytesToRead);
  12. if (n == )
  13. break;
  14. numBytesRead += n;
  15. numBytesToRead -= n;
  16. }
  17. numBytesToRead = bytes.Length;
  18. // 以UTF-8编码解码
  19. //string content = Encoding.UTF8.GetString(bytes);
  20. // 以GBK方式读取
  21. string content = Encoding.GetEncoding("GBK").GetString(bytes);
  22. fs.Close();
  23. MessageBox.Show(content);
  24. }
  25. }
  26. catch (System.IO.FileNotFoundException ioex)
  27. {
  28. MessageBox.Show("文件不存在","错误",MessageBoxButtons.OK,MessageBoxIcon.Error);
  29. }
  30. catch (Exception ex)
  31. {
  32. MessageBox.Show("其他错误", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
  33. }
  34. finally
  35. {
  36. }

StreamReader

  1. StreamReader sr = new StreamReader(fileName, Encoding.UTF8);
  2. string line;
  3. // 逐行读取
  4. while ((line = sr.ReadLine()) != null)
  5. {
  6. Console.WriteLine(line.ToString());
  7. }
  8. sr.Close();

ReadAllText

  1. if (System.IO.File.Exists(fileName))
  2. {
  3. // 默认以UTF-8编码读取
  4. //string content = System.IO.File.ReadAllText(fileName);
  5. // 以汉字GBK编码读取
  6. string content = System.IO.File.ReadAllText(fileName,Encoding.GetEncoding("GBK"));
  7. MessageBox.Show(content);
  8. }

ReadAllLines

  1. // 读取所有行
  2. foreach (var line in File.ReadAllLines(fileName))
  3. {
  4. Console.WriteLine(line);
  5. }

写入文件

FileStream

  1. // 以追加模式打开文件,当文件不存在时创建它
  2. using (FileStream fs = new FileStream(fileName, FileMode.Append, FileAccess.Write))
  3. {
  4. string content = "跟我一起做项目";
  5. // 以UTF-8编码写入
  6. //fs.Write(Encoding.UTF8.GetBytes(content), 0, Encoding.UTF8.GetByteCount(content));
  7. // 以GBK编码写入
  8. fs.Write(Encoding.GetEncoding("GBK").GetBytes(content), ,
  9. Encoding.GetEncoding("GBK").GetByteCount(content));
  10. fs.Close();
  11. MessageBox.Show("已写入");
  12. }

StreamWriter

  1. StreamWriter sw = File.AppendText(fileName);
  2. //开始写入
  3. sw.Write("跟我一起做项目\r\n");
  4. //清空缓冲区
  5. sw.Flush();
  6. //关闭流
  7. sw.Close();

AppendAllText

  1. // 如果文件存在则追加文本
  2. // 如果文件不存在则创建文件,并写入文本
  3. // 默认以UTF-8编码写入
  4. //File.AppendAllText(fileName, "追加文本\r\n",Encoding.UTF8);
  5. // 如果字符集选择了ASCII,那么写入的汉字将编程乱码
  6. //File.AppendAllText(fileName, "追加文本\r\n", Encoding.ASCII);
  7. // 以GBK编码写入
  8. File.AppendAllText(fileName, "追加文本\r\n", Encoding.GetEncoding("GBK"));

图像操作

图片打水印

  1. private void btnWrite_Click(object sender, EventArgs e)
  2. {
  3. // 从图片文件创建一个Image对象
  4. Image img = System.Drawing.Image.FromFile(imgName);
  5. // 创建一个Bitmap对象
  6. Bitmap bmp = new Bitmap(img);
  7. // 及时销毁img
  8. img.Dispose();
  9. // 从bpm创建一个Graphics对象
  10. Graphics graphics = Graphics.FromImage(bmp);
  11. // 指定在缩放或旋转图像时使用的算法
  12. // 使用高质量的双线性插值法。执行预筛选以确保高质量的收缩。
  13. // 需引用System.Drawing.Drawing2D
  14. graphics.InterpolationMode = InterpolationMode.HighQualityBilinear;
  15. // 定义单色画笔,用于填充图形形状,如矩形、椭圆、扇形、多边形和封闭路径。
  16. SolidBrush brush = new SolidBrush(Color.Red);
  17. // 定义起始位置
  18. PointF P = new PointF(, );
  19. // 定义字体
  20. Font font = new Font("微软雅黑", );
  21. // 绘制字符
  22. graphics.DrawString("这是绘制的文字", font, brush, P);
  23. // 以jpeg格式保存图像文件
  24. // System.Drawing.Imaging
  25. //bmp.Save(newImgName,ImageFormat.Jpeg);
  26. bmp.Save(newImgName, ImageFormat.Gif);
  27. // 销毁对象
  28. font.Dispose();
  29. graphics.Dispose();
  30. img.Dispose();
  31. this.pictureBox1.Image = bmp;
  32. }

修改图片格式

  1. private void btnSaveAs_Click(object sender, EventArgs e)
  2. {
  3. string imgName = appPath + "Penguins.jpg";
  4. Image img = System.Drawing.Image.FromFile(imgName);
  5. // 创建一个Bitmap对象
  6. Bitmap bmp = new Bitmap(img);
  7. // 另存为gif格式
  8. bmp.Save(appPath + "Penguins_new.gif", ImageFormat.Gif);
  9. // 另存为png格式
  10. bmp.Save(appPath + "Penguins_new.png", ImageFormat.Png);
  11. // 另存为bmp格式
  12. bmp.Save(appPath + "Penguins_new.bmp", ImageFormat.Bmp);
  13. // 销毁对象
  14. img.Dispose();
  15. }

创建缩略图

  1. private void btnThumbnail_Click(object sender, EventArgs e)
  2. {
  3. // 从图片文件创建image对象
  4. Image img = Image.FromFile(imgName);
  5. // 创建缩略图,指定宽度和长度
  6. // 提供一个回调方法,用于确定 GetThumbnailImage 方法应在何时提前取消执行
  7. Image thumbnailImage = img.GetThumbnailImage(, ,
  8. new Image.GetThumbnailImageAbort(ThumbnailCallback), IntPtr.Zero);
  9. thumbnailImage.Save(appPath + "Penguins_thum.jpg", ImageFormat.Jpeg);
  10. thumbnailImage.Dispose();
  11. img.Dispose();
  12. }

c#文件图片操作的更多相关文章

  1. media静态文件统一管理 操作内存的流 - StringIO | BytesIO PIL:python图片操作库 前端解析二进制流图片(了解) Admin自动化数据管理界面

    一.media ''' 1. 将用户上传的所有静态文件统一管理 -- settings.py -- MEDIA_ROOT = os.path.join(BASE_DIR, 'media') 2. 服务 ...

  2. Java文件IO操作应该抛弃File拥抱Paths和Files

    Java7中文件IO发生了很大的变化,专门引入了很多新的类: import java.nio.file.DirectoryStream;import java.nio.file.FileSystem; ...

  3. 【php学习】图片操作

    前两天要对一张图片进行处理,其实很简单,就是在图片上加上字符串,一个图片而已,但是自己如同得了短暂性失忆似的,图片操作的函数一个都想不起来.所以就抽空整理了一下图片操作函数. 图片处理三步走: 创建画 ...

  4. iOS开发——Swift篇&文件,文件夹操作

    文件,文件夹操作   ios开发经常会遇到读文件,写文件等,对文件和文件夹的操作,这时就可以使用NSFileManager,NSFileHandle等类来实现. 下面总结了各种常用的操作:   1,遍 ...

  5. c#基础语言编程-文件流操作

    引言 在System.IO 命名空间下提供了一系列的类,我们可以通过相应的类进行文件.目录.数据流的操作. 1.File类:提供用于创建.复制.删除.移动和打开文件的静态方法.File类 2.File ...

  6. Android应用程序开发之图片操作(一)——Bitmap,surfaceview,imageview,Canvas

    Android应用程序开发之图片操作(一)——Bitmap,surfaceview,imageview,Canvas   1,Bitmap对象的获取 首先说一下Bitmap,Bitmap是Androi ...

  7. bootstrap-wysiwyg 结合 base64 解码 .net bbs 图片操作类

    using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Dr ...

  8. UWP中的文件相关操作

    最近开始做UWP开发,图省事儿就把自己之前一个Winform项目的一部分代码拷贝到了新写的UWP项目中来.整出了一些幺蛾子,下面做一个记录. 首先提一个重点就是:UWP里关于文件的操作尽量用Stora ...

  9. Kotlin入门(27)文件读写操作

    Java的文件处理用到了io库java.io,该库虽然功能强大,但是与文件内容的交互还得通过输入输出流中转,致使文件读写操作颇为繁琐.因此,开发者通常得自己重新封装一个文件存取的工具类,以便在日常开发 ...

随机推荐

  1. VS编译代码未通过,常见问题。

    问题一:LNK2028 这个问题一般是什么函数在哪里被引用.修改的方法是:先检查是否包含头文件,如果已经包含了头文件,则检查在源文件的"import.cpp"中是否包含了该lib文 ...

  2. 用C++向一个txt文档中写数据

    bool CMaked::WriteFileMake(CString filePath, const char *isChange) { ofstream file; //filePath为该txt文 ...

  3. BZOJ_2068_[Poi2004]SZP_树形DP

    BZOJ_2068_[Poi2004]SZP_树形DP Description Byteotian 中央情报局 (BIA) 雇佣了许多特工. 他们每个人的工作就是监视另一名特工. Byteasar 国 ...

  4. 设置yum源:

    1.企业    阿里开源镜像站:   http://mirrors.aliyun.com/ 搜狐开源镜像站: http://mirrors.sohu.com/ 网易开源镜像站: http://mirr ...

  5. springcloud学习资料汇总

    收集Spring Cloud相关的学习资料 学习Spring Cloud首先需要了解Spring Boot,不了解Spring Boot的同学戳这里Spring Boot学习资料汇总 重点推荐:Spr ...

  6. 【Teradata SQL】从中文数字字母混合字符串中只提取数字regexp_substr

    目标:从中文数字字母的字符串中只提取数字 sel regexp_substr('mint choc中文11国1','\d+')

  7. 从壹开始微服务 [ DDD ] 之九 ║从军事故事中,明白领域命令验证(上)

    烽烟 哈喽大家周二好呀,咱们又见面了,上周末掐指一算,距离 圣诞节 只有 5 周的时间了(如果你还不知道为啥我要提圣诞节这个时间点,可以看看我的第二系列开篇<之一 ║ D3模式设计初探 与 我的 ...

  8. go语言调度器源代码情景分析之一:开篇语

    专题简介 本专题以精心设计的情景为线索,结合go语言最新1.12版源代码深入细致的分析了goroutine调度器实现原理. 适宜读者 go语言开发人员 对线程调度器工作原理感兴趣的工程师 对计算机底层 ...

  9. 原生js查询、添加、删除类

    1.添加类 为标签添加一个class的类 如:<div id="box" class="box">内容</div> document.g ...

  10. Asp.Net Core Web应用程序—探索

    前言 作为一个Windows系统下的开发者,我对于Core的使用机会几乎为0,但是考虑到微软的战略规划,我觉得,Core还是有先了解起来的必要. 因为,目前微软已经搞出了两个框架了,一个是Net标准( ...