/// <summary> /// 创建文件 /// </summary> /// <param name="fileName">文件名称</param> /// <param name="content">文件内容</param> /// <param name="msg">错误消息</param> /// <returns></returns> public static bool CreateFile(ushort fileID, byte[] content, out string msg) { try { if (!cardReader.OpenReader(out msg)) { return(false); } //默认进行身份验证 if (!Auth()) { } //先选择根目录 cpuCard.SelectMF(); //创建文件夹(文件夹创建的时候大一点) cpuCard.CreateDFFile(fileID, content.Length + 100); //选择创建的文件夹 cpuCard.SelectFileById(fileID); //cpuCard.RemoveDF(); //cpuCard.SelectFileById(fileID); ApduMsg msgApd = cpuCard.CreateAndWriteContent(fixFileID, content); //先选择根目录 cpuCard.SelectMF(); if (!msgApd.IsSuccess) { msg = msgApd.Msg; return(false); } } catch (Exception ex) { msg = ex.Message; return(false); } finally { cardReader.CloseReader(); //run.Close(); } return(true); }
private void button4_Click(object sender, EventArgs e) { ApduMsg msg = CardReader.SelectMF(); DisplayLog(msg); }