public void FileUpload(FileInfo file, string filename,SoftwareRepositoryService.RepositoryServiceClient client) { FileStream fs = null; try { bool firsttime = true; fs = File.Open(file.FullName, FileMode.Open, FileAccess.Read); int bytesRead = 0; //int count = 0; while (true) { long BlockSize = 5000; long Remainder = (int)(fs.Length - fs.Position); if (Remainder == 0) break; long size = Math.Min(BlockSize, Remainder); byte[] block = new byte[size]; bytesRead = fs.Read(block, 0, block.Length); client.UploadPackages(filename, block, firsttime); firsttime = false; } fs.Close(); return; } catch { if (fs != null) fs.Close(); return; } }