コード例 #1
0
        private void TestReadFileWinAPI2()
        {
            // This function tests out the Windows API function ReadFile.  This test tests out the ReadUntilEOF method
            // in the WinFileIO class.
            String S;
            int    FileLoop;

            try
            {
                // Get how fast it takes to read in the .683MB, 10MB, and 50MB files into memory.
                for (FileLoop = 0; FileLoop < 3; FileLoop++)
                {
                    Stopwatch stopwatch = Stopwatch.StartNew();
                    WFIO.OpenForReading(FileNames[FileLoop]);
                    WFIO.ReadUntilEOF();
                    WFIO.Close();
                    stopwatch.Stop();

                    S = "   Total time reading " + FileDesc[FileLoop] + " with WFIO2.ReadUntilEOF No Parsing		= "+ stopwatch.Elapsed.TotalMilliseconds.ToString();
                    DispUIMsg(S);
                }
            }
            catch (System.Exception ex)
            {
                S = "TestReadFileWinAPI2: threw an exception of type " + ex.GetType().ToString();
                DispUIMsg(S);
                DispUIMsg(ex.Message);
            }
        }
コード例 #2
0
        private void TestReadUntilEOF()
        {
            // This function tests the ReadUntilEOF function.
            int    BytesRead, Loop;
            String S;

            try
            {
                WFIO.OpenForReading(TestFileName);
                BytesRead = WFIO.ReadUntilEOF();
                WFIO.Close();
                // Check to see if the data read in matches the verification buffer.
                if (BytesRead != VerBytesRead)
                {
                    S = "  TestReadUntilEOF: test failed - bytes read != VerBytesRead";
                    DispUIMsg(S);
                    return;
                }
                // Compare the 2 arrays.  If there are any differences, then report an error.
                for (Loop = 0; Loop < BytesRead; Loop++)
                {
                    if (ByteBuf[Loop] != ByteBufVer[Loop])
                    {
                        S = "  TestReadUntilEOF: test failed - the " + Loop.ToString() + " element does not match the verification buffer.";
                        DispUIMsg(S);
                        return;
                    }
                }
                S = "  TestReadUntilEOF: Passed";
                DispUIMsg(S);
            }
            catch (System.Exception ex)
            {
                S = "  TestReadUntilEOF: threw an exception of type " + ex.GetType().ToString();
                DispUIMsg(S);
                S = "  " + ex.Message;
                DispUIMsg(S);
            }
        }
コード例 #3
0
 public void TestReadFileWinApi2(string pathToFile)
 {
     _wfio.OpenForReading(pathToFile);
     _wfio.ReadUntilEOF();
     _wfio.Close();
 }