新手在网上弄的一个代码,如下
public string PrintLine(string str)
            {
                try
                {
                    IntPtr iHandle = CreateFile(prnPort, 0x40000000, 0, 0, OPEN_EXISTING, 0, 0);
                    if (iHandle.ToInt32() == -1)
                    {
                        return "打印机打开失败";
                    }
                    else
                    {
                        FileStream fs = new FileStream(iHandle, FileAccess.ReadWrite);
                        
                        StreamWriter sw = new StreamWriter(fs, Encoding.Default);
                        sw.WriteLine(str);
                        sw.Close();
                        fs.Close();
                        return "";
                    }
                }
                    catch(Exception)
                   {
                    throw;
                    }
                }
其中 FileStream fs = new FileStream(iHandle, FileAccess.ReadWrite);这个系统会有如下提醒:、警告 1 “System.IO.FileStream.FileStream(System.IntPtr, System.IO.FileAccess)”已过时:“This constructor has been deprecated.  Please use new FileStream(SafeFileHandle handle, FileAccess access) instead.  http://go.microsoft.com/fwlink/?linkid=14202”要怎么改一下就好了呢?