Ho costruito questo script lato client che, una volta selezionato il file, cliccando sul bottone invia uno stream di data ad un web service:
codice:
protected void Invia_Click(object sender, EventArgs e)
{
localhost.Service l = new localhost.Service();
HttpPostedFile fileSent = PostedFile.PostedFile;
int fileSize = fileSent.ContentLength;
byte[] dati = new byte[fileSize];
fileSent.InputStream.Read(dati, 0, fileSize);
TextBox1.Text = l.myService(dati).ToString();
TextBox2.Text = fileSize.ToString();
}
Puo' essere giusto?
Ora nel webservice salvo il file sul server:
codice:
[WebMethod]
public int myService(byte[] myStreamFile)
{
int fileSize = myStreamFile.Length;
string filename = "prova.txt";
string filePath = "D:\\" + filename;
FileStream fs = new FileStream(filePath, FileMode.Create);
fs.Write(myStreamFile, 0, fileSize);
fs.Close();
Io vorrei a questo punto mandare il file in stampa su una stampante virtuale, esiste un modo per farlo dal web service?
Grazie