コード例 #1
0
ファイル: SymSession.cs プロジェクト: daumiller/SymSharp
        //========================================================================
        public string FileRead(string name, SymFile.Type type)
        {
            StringBuilder content = new StringBuilder();

              SymCommand cmd = new SymCommand("File");
              cmd.SetParam("Action", "Retrieve");
              cmd.SetParam("Type"  , SymFile.TypeString(type));
              cmd.SetParam("Name"  , name);
              Write(cmd);

              while(true)
              {
            cmd = ReadCommand();
            if(cmd.HasParam("Status"))
            {
              if(cmd.GetParam("Status").IndexOf("No such file or directory") != -1)
            throw new FileNotFoundException("File \""+name+"\" Not Found");
              else if(cmd.GetParam("Status").IndexOf("Cannot view a blank report") != -1)
            return "";
              else
            throw new Exception("Filename Too Long");
            }

            string chunk = cmd.GetFileData();
            if((chunk.Length > 0) || (type == SymFile.Type.REPORT))
            {
              content.Append(chunk);
              if(type==SymFile.Type.REPORT)
            content.Append('\n');
            }

            if(cmd.HasParam("Done"))
              break;
              }
              return content.ToString();
        }