alfinete
Power Member
tenho estes dois metodos para upload de ficheiros
mas com ficheiros um pouco maiores que 4 megas da o erro que se segue
gostava de um help
Código:
private bool upLoad()
{
bool resul = true;
//***** temporariamente inibido
string base_path_dir;
//string base_path_dir2;
//*****
HttpPostedFile httppf_decisoes = null;
// HttpPostedFile httppf_decisoes2;
int nFileLen;
//, nFileLen2
byte[] myData;
//,myData2
// procura o caminho de onde esta a aplicação
//string caminho = Server.MapPath("~/");
//***** Directório base
base_path_dir = @"" + upload;
//base_path_dir2 = @"" + upload2;
//***** UpLoad file -
try
{
httppf_decisoes = Fudocumento.PostedFile;
}
catch (Exception ex)
{
int a = 0;
}
//httppf_decisoes2 = Fudocumento.PostedFile;
string strFilename_pro = base_path_dir + @"\" + Path.GetFileName(Fudocumento.PostedFile.FileName);
//string strFilename_pro2 = base_path_dir2 + @"\" + Path.GetFileName(Fudocumento.PostedFile.FileName);
nFileLen = httppf_decisoes.ContentLength;
//nFileLen2 = httppf_decisoes2.ContentLength;
myData = new byte[nFileLen];
//myData2 = new byte[nFileLen2];
httppf_decisoes.InputStream.Read(myData, 0, nFileLen);
// httppf_decisoes2.InputStream.Read(myData2, 0, nFileLen2);
grava_upLoad(strFilename_pro, myData);
// grava_upLoad(strFilename_pro2, myData2);
return resul;
}
private bool grava_upLoad(string strPath, byte[] Buffer)
{
FileStream newFile;
bool resul = true;
// Create a file
newFile = new FileStream(strPath, FileMode.Create);
//buff = Buffer.Length;
// Write data to the file
//if (buff <= 3900000)
//{
newFile.Write(Buffer, 0, Buffer.Length);
// Close file
newFile.Close();
//}
//if (buff > 3900000)
//{
resul = false;
Lbldoc.Text = "Tamanho de Ficheiro inválido, Maximo 3,9 megas ";
//}
return resul;
}
mas com ficheiros um pouco maiores que 4 megas da o erro que se segue
gostava de um help