TempFileStream GetTempStream ()
{
string tempdir = AppDomain.CurrentDomain.SetupInformation.DynamicBase;
TempFileStream f = null;
string path;
Random rnd = new Random ();
int num;
do {
num = rnd.Next ();
num++;
path = System.IO.Path.Combine (tempdir, "tmp" + num.ToString("x") + ".req");
try {
f = new TempFileStream (path);
} catch (SecurityException) {
// avoid an endless loop
throw;
} catch { }
} while (f == null);
return f;
}