static async void DownloadFiles() { m_server = new Server("127.0.0.1", Convert.ToInt32(m_port)); await m_server.WaitForConnect(); await m_server.fileTrans.SendFiles(HHI_Module.m_dataPath); Console.WriteLine("data files sent."); NStream stream = m_server.stream; Int32 nfileCount = await stream.ReadInt32(); m_path = await stream.ReadString(); if (false == System.IO.Directory.Exists(m_path)) { //创建pic文件夹 System.IO.Directory.CreateDirectory(m_path); } System.Console.WriteLine("Client:" + "" + " Start uploading."); System.Console.WriteLine("[File Count]:" + nfileCount.ToString()); for (int i = 0; i < nfileCount; i++) { System.Console.WriteLine("\t[File Index]:" + i.ToString()); // 获得文件信息 long fileLength = await stream.ReadInt64(); string fileName = await stream.ReadString(); System.Console.WriteLine("\t\t[File Name]:" + fileName); System.Console.WriteLine("\t\t[File Length]:" + fileLength.ToString()); FileStream fileStream = File.Open(m_path + "/" + fileName, FileMode.Create); await stream.ReadBigTo(fileStream, fileLength); System.Console.WriteLine("\t[File]:" + fileName + "Received.\n"); } }