C# File.SetLastWriteTime的代码示例
通过代码示例来学习C# File.SetLastWriteTime方法
通过代码示例来学习编程是非常高效的。
1. 代码示例提供了一个具体而直观的学习环境,使初学者能够立即看到编程概念和语法的实际应用。
2. 通过分析和模仿现有的代码实例,初学者可以更好地理解编程逻辑和算法的工作原理。
3. 代码实例往往涵盖了多种编程技巧和最佳实践,通过学习和模仿这些实例,学习者可以逐步掌握如何编写高效、可读性强和可维护的代码。这对于初学者来说,是一种快速提升编程水平的有效途径。
File.SetLastWriteTime是C#的System.IO命名空间下中的一个方法, 小编为大家找了一些网络大拿们常见的代码示例,源码中的File.SetLastWriteTime() 已经帮大家高亮显示了,大家可以重点学习File.SetLastWriteTime() 方法的写法,从而快速掌握该方法的应用。
File.SetLastWriteTime的代码示例1 - SaveStream()
using System.IO; // ReSharper disable UnusedMethodReturnValue.Local private static long SaveStream(Stream stream, string path, DateTime touchDate, int streamBufferSize) // ReSharper restore UnusedMethodReturnValue.Local { FilePreparePath(path); long len = 0; using (FileStream fs = new FileStream(path, FileMode.Create, FileAccess.Write)) { using (BinaryReader br = new BinaryReader(stream)) { using (BinaryWriter bw = new BinaryWriter(fs)) { byte[] buffer; do { buffer = br.ReadBytes(streamBufferSize); len += buffer.Length; if (buffer.Length > 0) { bw.Write(buffer); } } while (buffer.Length > 0); bw.Flush(); } } } File.SetLastWriteTime(path, touchDate); return len; }
开发者ID:zzzprojects,项目名称:html-agility-pack,代码行数:35,代码来源:HtmlWeb.cs
在SaveStream()方法中,File的代码示例类中的SetLastWriteTime的代码示例方法一共出现了1次, 见黄色背景高亮显示的地方,欢迎大家点赞
File.SetLastWriteTime的代码示例2 - ExtractToFile()
using System.IO; private static void ExtractToFile(ZipArchiveEntry source, string destinationFileName, bool overwrite) { if (source == null) { throw new ArgumentNullException(nameof(source)); } if (destinationFileName == null) { throw new ArgumentNullException(nameof(destinationFileName)); } FileMode fMode = overwrite ? FileMode.Create : FileMode.CreateNew; using (FileStream fs = new FileStream(destinationFileName, fMode, FileAccess.Write, FileShare.None, bufferSize: 0x1000, useAsync: false)) using (Stream es = source.Open()) using (MaxLengthStream maxLengthStream = new MaxLengthStream(es, source.Length)) { maxLengthStream.CopyTo(fs); } File.SetLastWriteTime(destinationFileName, source.LastWriteTime.DateTime); }
开发者ID:ShareX,项目名称:ShareX,代码行数:25,代码来源:ZipManager.cs
在ExtractToFile()方法中,File的代码示例类中的SetLastWriteTime的代码示例方法一共出现了1次, 见黄色背景高亮显示的地方,欢迎大家点赞
本文中的File.SetLastWriteTime方法示例由csref.cn整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。