I cannot see where you got this exception. Writing to the file with the name obtained
System.IO.Path.GetTempFileName()
is perfectly legal. If the file name was empty (how your error message suggests), the error message would be different ("Empty path name is not legal"). So, I suspect your exception report is not 100% accurate. Not to worry — you don't need to do this.
First, please understand that the memory stream is quite useless. Yes, you can read and write to it, but how can you make Acrobat Reader 9 doing it? This application probably has nothing to do with .NET.
So, unfortunately, you're bound to use a temporary file. If your last code sample works, use it, only assign your variable
filpath
to temporary file name:
string filpath = System.IO.Path.GetTempFileName();
—SA