Вы должны либо хранить в какой-то очереди свои открытые узлы, либо каждый раз заполнять всю карту:
bool NextFill(int (&map)[MAX_SIZE][MAX_SIZE], int n)
{
const int offx = {-1, 0, 0, 1};
const int offy = {0, -1, 1, 0}
bool found = false;
for (int x = 0; x != MAX_SIZE; ++x) {
for (int y = 0; y != MAX_SIZE; ++y) {
if (map[x][y] == n) {
for (int i = 0; i != 4) {
auto& neighbor = map[x + offx[i]][y + offy[i]];
if (neighbor == -1) { /*Nothing*/ } // wall
else if (neighbor == -2) { found = true; } // Found
else if (neighbor == 0) { neighbor = n + 1; } // unvisited
// else {/*Nothing*/} // Already visited.
}
}
}
}
return found;
}
Отключите буферизацию ответа с context.Response.BufferOutput = false;
и удалите Flush
звоните от конца Вашего кода.
используйте Ответ. BufferOutput = ложь; в начале ProcessRequest и ответа сброса после каждого файла.
Отметьте это сообщение: http://www.nablasoft.com/alkampfer/index.php/2008/08/26/use-icsharpcodesharpziplib-to-write-directly-to-responseoutputstream-in-a-aspnet-application/
FYI. Это рабочий код для рекурсивного добавления целого дерева файлов, с потоковой передачей в браузер:
string path = @"c:\files";
Response.Clear();
Response.ContentType = "application/zip";
Response.AddHeader("Content-Disposition", string.Format("attachment; filename=\"{0}\"", "hive.zip"));
Response.BufferOutput = false;
byte[] buffer = new byte[1024 * 1024];
using (ZipOutputStream zo = new ZipOutputStream(Response.OutputStream, 1024 * 1024)) {
zo.SetLevel(0);
DirectoryInfo di = new DirectoryInfo(path);
foreach (string file in Directory.GetFiles(di.FullName, "*.*", SearchOption.AllDirectories)) {
string folder = Path.GetDirectoryName(file);
if (folder.Length > di.FullName.Length) {
folder = folder.Substring(di.FullName.Length).Trim('\\') + @"\";
} else {
folder = string.Empty;
}
zo.PutNextEntry(new ZipEntry(folder + Path.GetFileName(file)));
using (FileStream fs = File.OpenRead(file)) {
ICSharpCode.SharpZipLib.Core.StreamUtils.Copy(fs, zo, buffer);
}
zo.Flush();
Response.Flush();
}
zo.Finish();
}
Response.Flush();