Subir Archivos a Document Library

18/11/2008 - 17:39 por Tito | Informe spam
Hola buenas tardes, estoy tratando de subir archivos programaticamente
mediante un webpart, con el siguiente codigo:

SPWeb st_w = SPControl.GetContextWeb(Context);

string path_fil =
System.IO.Path.GetFileName(flup.PostedFile.FileName);

Stream str = flup.PostedFile.InputStream;

byte[] dt_by = new byte[str.Length];

str.Read(dt_by,(int)str.Length, 0);
str.Close();

string url_doc = st_w.Url + "/Document_Temp/";

SPFolder docfolder = st_w.Folders[url_doc];

SPFile docfile;

docfile = docfolder.Files.Add(path_fil, dt_by);

docfile.Update();

Donde la variable Flup es un objeto fileupload, el probleme es que aunque
sube el fichero los sube todos corruptos, alguien sabe como arreglar eso?,
gracias y un saludo.
 

Leer las respuestas

#1 Carlos Rodriguez
18/11/2008 - 19:57 | Informe spam
Hola Tito

aqui tienes una web part ejemplo

http://www.codeplex.com/SPUpload

Carlitos
http://www.aprendaMOSS.com


"Tito" wrote in message
news:
Hola buenas tardes, estoy tratando de subir archivos programaticamente
mediante un webpart, con el siguiente codigo:

SPWeb st_w = SPControl.GetContextWeb(Context);

string path_fil > System.IO.Path.GetFileName(flup.PostedFile.FileName);

Stream str = flup.PostedFile.InputStream;

byte[] dt_by = new byte[str.Length];

str.Read(dt_by,(int)str.Length, 0);
str.Close();

string url_doc = st_w.Url + "/Document_Temp/";

SPFolder docfolder = st_w.Folders[url_doc];

SPFile docfile;

docfile = docfolder.Files.Add(path_fil, dt_by);

docfile.Update();

Donde la variable Flup es un objeto fileupload, el probleme es que aunque
sube el fichero los sube todos corruptos, alguien sabe como arreglar eso?,
gracias y un saludo.

Preguntas similares