Artículos con la etiqueta upload
Carga de Archivo (Upload File) desde infopath forms services
diciembre 05, 2009Deben utilizar un botón adicional al cual le añaden el siguiente codigo .net:
public void btnCargarDocumento_Clicked(object sender, ClickedEventArgs e)
{
XPathNavigator DOM = this.MainDataSource.CreateNavigator();
XPathNavigator fileDocumento = DOM.SelectSingleNode("/my:misCampos/my:att_documento", NamespaceManager);
byte[] attachmentNodeBytes = Convert.FromBase64String(fileDocumento.Value.ToString());
int fnLength = attachmentNodeBytes[20] * 2;
byte[] fnBytes = new byte[fnLength];
for (int i = 0; i < fnBytes.Length; i++)
{
fnBytes[i] = attachmentNodeBytes[24 + i];
}
char[] charFileName = System.Text.UnicodeEncoding.Unicode.GetChars(fnBytes);
string fileName = new string(charFileName);
fileName = txtIdActividad.Value + "-" + fileName.Substring(0, fileName.Length - 1);
byte[] fileContents = new byte[attachmentNodeBytes.Length - (24 + fnLength)];
for (int i = 0; i < fileContents.Length; ++i)
{
fileContents[i] = attachmentNodeBytes[24 + fnLength + i];
}
string LibreriaDestino = "http://SERVIDOR:8001/sitio/sitiodocs/documentosA/";
string Destino = LibreriaDestino + fileName;
System.Net.WebClient objWebClient = new System.Net.WebClient();
objWebClient.Credentials = System.Net.CredentialCache.DefaultCredentials;
objWebClient.UploadData(Destino, "PUT", fileContents);
//limpiar el control upload
if (!fileDocumento.MoveToAttribute("nil",
fileDocumento.LookupNamespace("xsi")))
{
fileDocumento.SetValue("");
}
}
Espero que sea de ayuda





