Ver Mensaje Individual
  #2 (permalink)  
Antiguo 13/05/2010, 12:47
Avatar de jaullo
jaullo
 
Fecha de Ingreso: abril-2009
Mensajes: 994
Antigüedad: 15 años
Puntos: 30
Respuesta: Guardar imagen con FileUpload

Esta linea no deberia ser

string extension = System.IO.Path.GetExtension(nombrearchivo);

Segundo para saber la extension tienes que decirle de donde, es decir darle una variable. Por ejemplo

if (FileUpload1.HasFile) {
string fileExt = null;
fileExt = System.IO.Path.GetExtension(FileUpload1.FileName);


// If (fileExt = ".mp3") Then
try {
FileUpload1.SaveAs(apppath + FileUpload1.FileName);
Label1.Text = "File name: " + FileUpload1.PostedFile.FileName + "<br>" + "File Size: " + FileUpload1.PostedFile.ContentLength + " kb<br>" + "Content type: " + FileUpload1.PostedFile.ContentType;
} catch (Exception ex) {
Label1.Text = "ERROR: " + ex.Message.ToString();
}
} else {
Label1.Text = "Only .mp3 files allowed!";
}