How To: Write files containing device names

May 15 2006 10:12 PM
I have an application that exports data from a database. The file names are determined by the information in the database. My code looks like

System.IO.StreamWriter sw = System.IO.File.CreateText("c:\\temp\\" + dataname + ".txt");

The problem is, some of the data items are the same as system devices. So if I try to write to the file c:\temp\prn.txt I get the error "Filestream will not open Win32 devices such as disk partitions and tape drives. Avoid use of \\.\ in the path"

Does anyone know how to avoid this problem? I have no control over the data names created in the database and the file names need to match.

Thanks
Spike.