Stampa di un file Txt

martedì 12 agosto 2003 - 18.46

trinity Profilo | Guru

Ragazzi sapete come stampare in vb net un file txt che si trova in una cartella? E possibilmente prima di stamparlo poterlo far visualizzare a video?

ciao

Brainkiller Profilo | Guru

Ciao Trinity,
se tu guardi nel Framework SDK trovi tutto, ti incollo un esempietto:

// Print the file.
public void Printing()
{
try
{
streamToPrint = new StreamReader (filePath);
try
{
printFont = new Font("Arial", 10);
PrintDocument pd = new PrintDocument();
pd.PrintPage += new PrintPageEventHandler(pd_PrintPage);
// Print the document.
pd.Print();
}
finally
{
streamToPrint.Close() ;
}
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
}
}

Se vuoi visualizzare prima il file puoi eseguire un comando esterno tramite il seguente Tip:
http://www.dotnethell.it/tips/tip.aspx?TipID=31

E lanciare per esempio il notepad.exe seguito dal nome del file. Appena visualizzato invii anche la stampa.
Ciao

David De Giacomi
Partecipa anche tu! Registrati!
Hai bisogno di aiuto ?
Perchè non ti registri subito?

Dopo esserti registrato potrai chiedere
aiuto sul nostro Forum oppure aiutare gli altri

Consulta le Stanze disponibili.

Registrati ora !
Copyright © dotNetHell.it 2002-2024
Running on Windows Server 2008 R2 Standard, SQL Server 2012 & ASP.NET 3.5