Ver Mensaje Individual
  #1 (permalink)  
Antiguo 20/11/2009, 19:06
artspider
 
Fecha de Ingreso: junio-2009
Mensajes: 115
Antigüedad: 14 años, 11 meses
Puntos: 1
Sonrisa Problemas archivo

Saludos lo que pasa que tengo un problema en mi aplicación, creo un archivo, cuando corro localmente mi aplicación me crea bien mi archivo, pero cuando subo mi proyecto al IIS, no me deja crearlo me marca error, que es el siguiente:

Access to the path 'C:\WINDOWS\system32\test.txt' is denied


coloco el código con el que genero mi archivo:

string fileName = "test.txt";

using (System.IO.FileStream fs = System.IO.File.Create(fileName, 1024))
{
Response.Clear();
Response.AppendHeader("Content-Disposition:", "attachment; filename=Liberacion.txt");
//Response.AppendHeader("Content-Length", resp.ContentLength.ToString());
Response.ContentType = "text/plain";

// Add some information to the file.
if (Excepciones.Length == 0)
Excepciones = "No hay Información para mostrar";

int bufferSize = 1;
byte[] ByteBuffer = new byte[bufferSize - 1];
byte[] info = new System.Text.UTF8Encoding(true).GetBytes(Excepcione s);

MemoryStream ms = new MemoryStream(info, true);
byte[] bytes = new byte[bufferSize + 1];
int tamano = ByteBuffer.Length;
/*while (ms.Read(ByteBuffer, 0, ByteBuffer.Length) > 0)
{

}*/
ms.Read(ByteBuffer, 0, ByteBuffer.Length);
try
{
Response.BinaryWrite(ms.ToArray());
Response.Flush();
}
catch (Exception excep)
{
throw new InsysExcep(log4net.Core.Level.Error, "El archivo no se creo.", excep);
}
finally {
//Cleanup
Response.End();
ms.Close();
ms.Dispose();
ByteBuffer = null;
}