예제 #1
0
        private void TestReadFileWinAPI1()
        {
            // This function tests out the Windows API function ReadFile.  This function tests the ReadFile function
            // by reading in the entire file with one call.
            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.Read(BufSizeM1M);
                    WFIO.Close();
                    stopwatch.Stop();

                    S = "   Total time reading " + FileDesc[FileLoop] + " with WFIO1.Read No Parsing			= "
                        + stopwatch.Elapsed.TotalMilliseconds.ToString();
                    DispUIMsg(S);
                }
            }
            catch (System.Exception ex)
            {
                S = "TestReadFileWinAPI1: threw an exception of type " + ex.GetType().ToString();
                DispUIMsg(S);
                DispUIMsg(ex.Message);
            }
        }
예제 #2
0
        private void TestRead()
        {
            // This function tests the Read function.
            int    BytesRead, Loop;
            String S;

            try
            {
                WFIO.OpenForReading(TestFileName);
                BytesRead = WFIO.Read(BufSize);
                WFIO.Close();
                // Check to see if the data read in matches the verification buffer.
                if (BytesRead != VerBytesRead)
                {
                    S = "  TestRead: 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 = "  TestRead: test failed - the " + Loop.ToString() + " element does not match the verification buffer.";
                        DispUIMsg(S);
                        return;
                    }
                }
                S = "  TestRead: Passed";
                DispUIMsg(S);
            }
            catch (System.Exception ex)
            {
                S = "  TestRead: threw an exception of type " + ex.GetType().ToString();
                DispUIMsg(S);
                S = "  " + ex.Message;
                DispUIMsg(S);
            }
        }
 public void TestReadFileWinApi1(string pathToFile)
 {
     _wfio.OpenForReading(pathToFile);
     _wfio.Read(BufSizeM1M);
     _wfio.Close();
 }