Microsoft.JScript.JSInProcCompiler.ReadFile C# (CSharp) Method

ReadFile() protected method

protected ReadFile ( string fileName, VsaEngine engine ) : string
fileName string
engine Microsoft.JScript.Vsa.VsaEngine
return string
      protected string ReadFile(string fileName, VsaEngine engine){
        string s = "";
        FileStream inputStream = null;
        try{
          inputStream = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read);
        }catch(System.ArgumentException){
          throw new CmdLineException(CmdLineError.InvalidCharacters, fileName, engine.ErrorCultureInfo);
        }catch(System.IO.FileNotFoundException){
          throw new CmdLineException(CmdLineError.SourceNotFound, fileName, engine.ErrorCultureInfo);
        }
        try {
          if (inputStream.Length != 0) {
            StreamReader reader = new StreamReader(inputStream, true /*detectEncodingFromByteOrderMarks*/);
            try{
              s = reader.ReadToEnd();
            }finally{
              reader.Close();
            }
          }
        }finally{
          inputStream.Close();
        }
        return s;
      }