I'm trying to make a dialog to get a path through the OpendFileDialog, but I skip the exception System.Threading.ThreadStateException
.
The application is a WebAplication
, hosted on a server. Therefore, the PDF must be generated in a local directory of the user who is using it. For this I want to get the Path
desired.
The code is as follows:
private string nombreFile()
{
OpenFileDialog ofg = new OpenFileDialog();
DialogResult rst = ofg.ShowDialog();
string n = "";
if (rst == DialogResult.OK)
{
n = ofg.FileName;
}
return n;
}
private void imprimir()
{
string nomF = nombreFile();
string nombre = nomF + Guid.NewGuid().ToString() + ".pdf";
Document doc = new Document(PageSize.A4, 50, 50, 25, 25);
doc.Open();
//GENERAMOS EL CONTENIDO DEL PDF
doc.Close();
//Imprimimos el doc
Process prc = new Process();
prc.StartInfo.FileName = nombre;
prc.Start();
}
What I want to achieve is that the nombre
that is passed to the Process
is the nomF
, path generated by the nombreFile()
but I skip that exception.