private void DownFileCallBack(IAsyncResult ra) { CustomFile customFile = (CustomFile)ra.AsyncState; int currentLen = customFile.FileStream.EndRead(ra); if (currentLen != 0) { CustomFileInfo customFileInfo = new CustomFileInfo(); customFileInfo.CurrentData = customFile.CurrentByte; customFileInfo.CurrentOffset = customFile.FileStream.Position - currentLen; customFileInfo.FileLength = customFile.FileStream.Length; customFileInfo.CurrentLen = currentLen; customFileInfo.FileName = customFile.FileName; if (customFile.ClientCallBack.DownFile(customFileInfo)) { customFile.FileStream.BeginRead(customFile.CurrentByte, 0, customFile.MaxLength, (AsyncCallback)DownFileCallBack, customFile); } else { customFile.FileStream.Close(); customFile.FileStream.Dispose(); } } else { customFile.FileStream.Close(); customFile.FileStream.Dispose(); } }
public void UploadFile(CustomFileInfo currentUploadFile) { FileStream fs = new FileStream(currentUploadFile.ServerPath + "\\" + currentUploadFile.FileName, FileMode.OpenOrCreate, FileAccess.Write); fs.Seek(currentUploadFile.CurrentOffset, SeekOrigin.Begin); fs.BeginWrite( currentUploadFile.CurrentData, 0, currentUploadFile.CurrentLen, new AsyncCallback(delegate(IAsyncResult ra) { fs.EndWrite(ra); fs.Close(); fs.Dispose(); }), null); }
public IAsyncResult BeginUploadFile(CustomFileInfo currentUploadFile, AsyncCallback ra, object state) { throw new NotImplementedException(); }