Upload PDF or P7S file to XML

Asked

Viewed 327 times

1

I have the following XML line of an XML Schema.

{**<nomeArquivoP7S><nomeArquivoP7S>**}

and I want to include a file in p7s of name copia1.pdf.p7s in this line, that is I want to upload this file in XML to be transmitted as follows:

{**<nomeArquivoP7S>copia1.pdf.p7s<nomeArquivoP7S>**}

What I understand is that he will have to read the directory where it is, find the file and load it?

It would look something like this?

string fichaconcatenada = fileName + ".pdf.p7s";

//string str = arroba + Caminhoconcatenado + fichaconcatenada;
string str = Caminhoconcatenado + "\\" + fichaconcatenada;

//string[] words = { arroba,"\\Imagens_SEFAZ\\", fichaconcatenada };
//var res = words.Aggregate((current, next) => current + "\\" + next);
FileStream stream =  new FileStream(@str, FileMode.Open);

// instanciando a variável do tipo BinaryReader
BinaryReader reader = new BinaryReader(stream);

// variáveis recebendo os valores lidos pelo arquivo binário
int lendointeiro = reader.ReadInt32();
string lendotexto = reader.ReadString();
Byte lendobool = reader.ReadByte();
//double conteudoArquivoP7S = reader.ReadDouble();
// fecha o acesso com o arquivo
reader.Close();
var bytes = Encoding.UTF8.GetBytes(fichaconcatenada);
var conteudoArquivoP7S = Convert.ToBase64String(bytes);

The detail is that in doing so, it brings me only the binary content and not the name+content.

How to do?

  • The question is very confusing, do you want the file name to track the binary content? Couldn’t you create (if there isn’t) a tag in this xml to put the file name? Try to add the xml between single quotes `` the result is entre aspas simples

  • Let’s see if I can be clear. I have the field (line) in XLM in the following format:{<filename P7S><filename P7S>} and I want to upload the file already scanned and in PDF as well as converted in Binario to the field, but with the name of the PDF and not in binary. I have an application that already in this format but the content goes up in binary.This new project wants me to attach the binary but with the original name... I don’t know if I was clear... like this ...{<nomeArquivoP7S>nomeescolhido1<nomeArquivoP7S>}

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.