06 2020 档案
摘要:class Dirs { public string DirName { get; set; } public long DirSize { get; set; } } static void OrderFiles(string dir) { string[] dirs = Directory.Ge
阅读全文
摘要:The piped stream are bidirectional communcation.Meanwhile they can read and write. Write the NamedPipeServerStream and NamedPipeClientStream in two di
阅读全文
摘要:static DataTable ReadExcelConvertToDataTable(string xlsxFileName) { DataTable dt = new DataTable(); try { IWorkbook book; using (FileStream fs = new F
阅读全文
摘要:1.Install-package npoi; 2.Add necessary namespace as below. using System.IO;using System.IO.Compression;using NPOI.HSSF.UserModel;using NPOI.SS.UserMo
阅读全文
摘要:Write the current to the local file. static void CopyStream(Stream stream, string destPath) { using (var fileStream = new FileStream(destPath, FileMod
阅读全文
摘要:static void AssemblyLoadContextDemo() { var assms = AssemblyLoadContext.All.SelectMany(x => x.Assemblies); if(assms!=null && assms.Any()) { foreach(va
阅读全文
摘要:1.Add resource file Resource1.resx via add new item in Console Application project; 2.Open Resource1.resx, Add Resource/Add Existing File, add multipl
阅读全文
摘要:1.Add new folder Resources in project; 2.Add resource such as picture in the Resource folder; 3.Set the picture's Build Action as Embedded Resource in
阅读全文
摘要:static void ComputeCodeLines() { string dir = @"D:\Work"; int totalLines = 0; string[] allFiles = Directory.GetFiles(dir, "*.cs", SearchOption.AllDire
阅读全文
摘要:using System; using System.Diagnostics; using System.IO; using System.Text; using System.Threading.Tasks; static StreamWriter Syncsw = new StreamWrite
阅读全文
摘要:static async void HttpClientSendAsync() { var client = new HttpClient(new HttpClientHandler { UseProxy = false }); var request = new HttpRequestMessag
阅读全文
摘要:static void WebRequestDemo() { WebRequest req = WebRequest.Create("https://5b0988e595225.cdn.sohucs.com/images/20180422/bd1d3910de4945a7996eee3c1eedd0
阅读全文
摘要:static void Main(string[] args) { Task task = Task.Run(() => { CreateRndTextFiles(); }); string path = Directory.GetCurrentDirectory(); FileSystemWatc
阅读全文
摘要:const int SupportsCompression = 0x10; const int SupportEncryption = 0x20000; [DllImport("Kernel32.dll", SetLastError = true)] extern static bool GetVo
阅读全文
摘要:static void FileInfoChangeReadOnly() { string file = @"D:\C\ConsoleApp24\ConsoleApp24\bin\Debug\netcoreapp3.1\ConsoleApp23\ConsoleApp23\bin\Debug\netc
阅读全文
摘要:static void ZipFolderDemo() { string path = Directory.GetCurrentDirectory(); string zippedFile = Path.Combine(path, path+".zip"); Console.WriteLine($"
阅读全文
摘要:static string dir = @"D:\C\ConsoleApp2"; static void GZipCompressDemo() { string[] filesArr = Directory.GetFiles(dir, "*", SearchOption.AllDirectories
阅读全文
摘要:static void ListTop20BiggestFile() { string str = @"D:\C"; var files = Directory.GetFiles(str, "*", SearchOption.AllDirectories).OrderByDescending(x =
阅读全文
摘要:using System; using System.IO; using System.IO.Compression; using System.Security.Cryptography; using System.Text; static void Main(string[] args) { D
阅读全文
摘要:static void BinaryWriterReaderDemo() { using (FileStream fs = new FileStream("fs.txt", FileMode.Create)) { SaveData(fs); } using(FileStream fs=new Fil
阅读全文
摘要:static void FileStreamWriterReadDemo() { string textFile = "fs.txt"; using (FileStream fs = new FileStream(textFile, FileMode.Create)) { using (Stream
阅读全文
摘要:using System.Globalization; static void GetCultureInfos() { var cultures = CultureInfo.GetCultures(CultureTypes.AllCultures).OrderBy(x => x.Name).ToLi
阅读全文
摘要:Named pipe (more flexible)Allows two-way communication between arbitrary processes on the same computer or different computers across a network.A pipe
阅读全文
摘要:static void FileStreamSDemo() { DateTime dtNow = DateTime.Now; DateTime dtEnd = dtNow.AddSeconds(60); using(FileStream fs=new FileStream("FileStream.t
阅读全文
摘要:static void Main(string[] args) { A(); Console.ReadLine(); } static void A() { B(); } static void B() { C(); } static void C() { StackTrace s = new St
阅读全文
DebuggerStepThrough requests that the debugger step through a function without any user interaction.
摘要:static void Main(string[] args) { DoWorkProxy(); Console.ReadLine(); } [DebuggerStepThrough,DebuggerHidden] static void DoWorkProxy() { PrintTime(); }
阅读全文