Пример #1
0
 public static void DeleteFile(ushort no)
 {
     for (ushort i = 1; i <= no; i++)
     {
         CPUCardWrapper.DeleteFile(i);
     }
 }
Пример #2
0
 private void button2_Click(object sender, EventArgs e)
 {
     if (CPUCardWrapper.DeleteFile(GetCurrentFileID()))
     {
         WireLog("删除成功");
     }
     else
     {
         WireLog("删除失败");
     }
 }
Пример #3
0
        /// <summary>
        /// 测试
        /// </summary>
        public static void TestMain()
        {
            //DateTime dt = DateTime.Now;
            ushort FileCount = 100;

            //DeleteFile(FileCount);
            //TestMaxFile();
            //Console.WriteLine();
            //return;



            for (ushort i = 1; i <= 100; i++)
            {
                int fileLenth = 1024;
                CPUCardWrapper.DeleteFile(i);
                byte[] data = new byte[fileLenth];

                r.NextBytes(data);


                if (TestFileByte(i, data))
                {
                    Console.WriteLine(" succ");
                }
                else
                {
                    Console.WriteLine(" false");
                }
            }


            return;

            for (int i = 100; i < 1024 * 70; i += 2000)
            {
                TestFile(1, GetRandomString(i));
            }
            return;


            for (ushort i = 1; i < FileCount; i++)
            {
                //测试文件大小
                int FileLenght = 1024;

                TestFile(i, GetRandomString(FileLenght));
            }
        }
Пример #4
0
        public static bool CreateFile(ushort fileID, string content, out string msg)
        {
            //写之前先清空分区
            CPUCardWrapper.DeleteFile(fileID);

            msg = "";

            byte[] data   = encod.GetBytes(content);
            bool   reslut = CreateFile(fileID, data, out msg);

            WriteLog("***********************\r\n");
            WriteLog($"写入文件{fileID}---- {reslut} ---- {msg} ---- {content}");
            WriteLog("***********************\r\n");
            return(reslut);
        }
Пример #5
0
        public static bool TestFile(ushort fileId, string fileContent)
        {
            bool     isPass  = true;
            DateTime dtStart = DateTime.Now;

            CPUCardWrapper.DeleteFile(fileId);

            if (!CPUCardWrapper.CreateFile(fileId, fileContent, out string msg))
            {
                Console.WriteLine("创建文件失败" + msg);
                isPass = false;
            }

            DateTime dtEnd = DateTime.Now;

            TimeSpan ts = dtEnd - dtStart;

            Console.WriteLine();
            dtStart = DateTime.Now;

            if (!CPUCardWrapper.ReadFile(fileId, out string m3sg))
            {
                Console.WriteLine("读取文件失败" + m3sg);
                isPass = false;
            }
            dtEnd = DateTime.Now;

            ts = dtEnd - dtStart;
            Console.WriteLine();

            if (isPass && fileContent != m3sg)
            {
                int count = fileContent.Length - m3sg.Length;
                Console.WriteLine("写入文件与读取文件不一致,读取比写入少" + count);
                isPass = false;
            }
            string result = "测试文件{0} ,测试长度{1},测试结果{2}";

            Console.WriteLine(string.Format(result, fileId, fileContent.Length, isPass ? "通过" : "不通过"));
            return(isPass);
        }