Example #1
0
        private static bool AssertFileMode(string file, FileMode mode)
        {
            bool flag = StdioFileStream.FileExists(file);

            if (mode == FileMode.CreateNew && flag)
            {
                throw new IOException("File exists and FileMode.CreateNew specified");
            }
            if ((mode == FileMode.Open || mode == FileMode.Truncate) && !flag)
            {
                throw new FileNotFoundException("File doesn't exist and FileMode.Open specified", file);
            }
            return(flag);
        }