public void nextname() { temp.name = name.text; name.text = ""; writefile wf = GameObject.Find("test").GetComponent <writefile>(); wf.Save(temp); closename(); showsuccess(); }
public static bool Open() { try { //if (!CommBase.ifUseOutside) { print = false; return false; } writefile wr = new writefile(WriteFile); int i = 0; OVERLAPPED x = new OVERLAPPED(); byte[] mybyte = System.Text.Encoding.Default.GetBytes(" "); mybyte[0] = 27; mybyte[1] = 64; if (iHandle == -1 || iHandle == 0) { iHandle = CreateFile("lpt1", GENERIC_WRITE, 0, 0, OPEN_EXISTING, 0, 0); } IAsyncResult ir = wr.BeginInvoke(iHandle, mybyte, 2, ref i, ref x, null, null); long dtstart = DateTime.Now.Ticks; long dtend = DateTime.Now.Ticks; while (!ir.IsCompleted) { //Application.DoEvents(); dtend = DateTime.Now.Ticks; if (dtend - dtstart >= 1000000) { throw new Exception(" "); } } print = wr.EndInvoke(ref i, ref x, ir); if (iHandle != INVALID_HANDLE_VALUE) { print = true; return(true); } else { throw new Exception(" "); //return false; } } catch { //if (CommBase.ShowMessage(CommBase.MessageMode.typeOKCancel, "无法连接打印机,是否继续操作不打印。") != CommBase.MessageMode.typeOK) //{ // Open();//继续检测打印机 //} //Open(); print = false; return(false); throw new Exception("无法连接打印机!"); } }