当前位置: 首页>>代码示例>>C#>>正文


C# System.IO.StreamReader.Read方法代码示例

本文整理汇总了C#中System.IO.StreamReader.Read方法的典型用法代码示例。如果您正苦于以下问题:C# System.IO.StreamReader.Read方法的具体用法?C# System.IO.StreamReader.Read怎么用?C# System.IO.StreamReader.Read使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.IO.StreamReader的用法示例。


在下文中一共展示了System.IO.StreamReader.Read方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Main

        static void Main(string[] args)
        {
            //Create a new proccess
            System.Diagnostics.Process proc = new System.Diagnostics.Process();
            //Path to the executable to run
            proc.StartInfo.FileName = "PstPassword.exe";
            //Command line arguments, paths to output file and .pst
            proc.StartInfo.Arguments = "/stext \"passwords.txt\" /pstfiles \"putyourfilenamehere.pst\"";
            proc.Start();
            proc.WaitForExit();

            System.IO.StreamReader reader = new System.IO.StreamReader("passwords.txt");
            string pw1, pw2, pw3;
            //buffer to dump unwanted character in for reading purposes.
            char[] c = new char[20];

            //Read past the first 6 lines
            reader.ReadLine();reader.ReadLine();reader.ReadLine();reader.ReadLine();reader.ReadLine();

            //read past Password 1      :
            reader.Read(c, 0, 20);
            //read in password
            pw1 = reader.ReadLine();
            //read past Password 2      :
            reader.Read(c, 0, 20);
            //read in password
            pw2 = reader.ReadLine();
            //read past Password 3      :
            reader.Read(c, 0, 20);
            //read in password
            pw3 = reader.ReadLine();

            Console.WriteLine(pw1 + ", " + pw2 + ", " + pw3);
        }
开发者ID:mtotheikle,项目名称:EWU-OIT-SSN-Scanner,代码行数:34,代码来源:Program.cs

示例2: UploadFileTest

        public void UploadFileTest()
        {
            var req = (HttpWebRequest)HttpWebRequest.Create("http://alex/asc/products/files/Services/WCFService/Service.svc/folders/files?id=1");

            req.Method = "POST";
            req.ContentType = "application/octet-stream";
            var reqStream = req.GetRequestStream();

            var fileToSend = System.IO.File.ReadAllBytes(@"c:\1.odt");

            reqStream.Write(fileToSend, 0, fileToSend.Length);
            reqStream.Close();

            var resp = (HttpWebResponse)req.GetResponse();

            var sr = new System.IO.StreamReader(resp.GetResponseStream(), Encoding.Default);
            var count = 0;
            var ReadBuf = new char[1024];
            do
            {
                count = sr.Read(ReadBuf, 0, 1024);
                if (0 != count)
                {
                    Console.WriteLine(new string(ReadBuf));
                }

            } while (count > 0);
            Console.WriteLine("Client: Receive Response HTTP/{0} {1} {2}", resp.ProtocolVersion, (int)resp.StatusCode, resp.StatusDescription);
        }
开发者ID:ridhouan,项目名称:teamlab.v6.5,代码行数:29,代码来源:Files.cs

示例3: RobotsNetwork

 /// <summary>
 /// Builds network.
 /// </summary>
 /// <param name="path">
 /// Path to file.
 /// </param>
 public RobotsNetwork(string path)
 {
     System.IO.StreamReader file = new System.IO.StreamReader(path);
     this.g = new Graph(file.Read() - 48);
     if (this.g.NumberOfVertex < 1)
         throw new IncorrectInputException();
     this.hereRobot = new bool[this.g.NumberOfVertex];
     file.ReadLine();
     file.ReadLine();
     while (true)
     {
         string[] temp = file.ReadLine().Split(' ');
         if (temp[0][0] == 'R')
             break;
         if (((temp[0][0] - 48) < 0) || ((temp[1][0] - 48) < 0) || ((temp[1][0] - 48) > (this.g.NumberOfVertex - 1)) || ((temp[0][0] - 48) > (this.g.NumberOfVertex - 1)))
             throw new IncorrectInputException();
         g.AddEdge(temp[0][0] - 48, temp[1][0] - 48);
     }
     string[] listRob = file.ReadLine().Split(' ');
     for (int i = 0; i < listRob.Length; ++i)
     {
         if (((listRob[i][0] - 48) < 0 ) || ((listRob[i][0] - 48) > this.g.NumberOfVertex - 1))
             throw new IncorrectInputException();
         this.hereRobot[listRob[i][0] - 48] = true;
     }
     this.classA = new bool[this.g.NumberOfVertex];
     this.classB = new bool[this.g.NumberOfVertex];
     this.visited = new bool[this.g.NumberOfVertex];
     this.Traverse(0, true);
 }
开发者ID:Ershov-Alexander,项目名称:for_study,代码行数:36,代码来源:RobotsNetwork.cs

示例4: DecodingFileFromFile

 /// <summary>
 /// 将一个由Base64编码产生的文件解码并存储到一个文件
 /// </summary>
 /// <param name="strBase64FileName">以Base64编码格式存储的文件</param>
 /// <param name="strSaveFileName">要输出的文件路径,如果文件存在,将被重写</param>
 /// <returns>如果操作成功,则返回True</returns>
 public static bool DecodingFileFromFile(string strBase64FileName, string strSaveFileName)
 {
     System.IO.StreamReader fs = new System.IO.StreamReader(strBase64FileName, System.Text.Encoding.ASCII);
     char[] base64CharArray = new char[fs.BaseStream.Length];
     fs.Read(base64CharArray, 0, (int)fs.BaseStream.Length);
     string Base64String = new string(base64CharArray);
     fs.Close();
     return DecodingFileFromString(Base64String, strSaveFileName);
 }
开发者ID:doscanner,项目名称:GF,代码行数:15,代码来源:Base64.cs

示例5: HTTP_POST

        public static string HTTP_POST(string Url, string Data)
        {
            string Out = String.Empty;
            System.Net.WebRequest req = System.Net.WebRequest.Create(Url);
            try
            {
                req.Method = "POST";
                req.Timeout = 100000;
                req.ContentType = "application/x-www-form-urlencoded";
                byte[] sentData = Encoding.UTF8.GetBytes(Data);
                req.ContentLength = sentData.Length;
                using (System.IO.Stream sendStream = req.GetRequestStream())
                {
                    sendStream.Write(sentData, 0, sentData.Length);
                    sendStream.Close();
                }
                System.Net.WebResponse res = req.GetResponse();
                System.IO.Stream ReceiveStream = res.GetResponseStream();
                using (System.IO.StreamReader sr = new System.IO.StreamReader(ReceiveStream, Encoding.UTF8))
                {
                    Char[] read = new Char[256];
                    int count = sr.Read(read, 0, 256);

                    while (count > 0)
                    {
                        String str = new String(read, 0, count);
                        Out += str;
                        count = sr.Read(read, 0, 256);
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return Out;
        }
开发者ID:yanjingzhan,项目名称:RecommendGameGod,代码行数:38,代码来源:HttpHelper.cs

示例6: JSONReader

        /// <summary> Constructor.</summary>
        /// <param name="filePath">- the file path of the plug-in configuration file
        /// </param>
        /// <throws>  JSONException </throws>
        /// <throws>  IOException </throws>
        public JSONReader(System.String filePath)
        {
            System.IO.StreamReader reader = new System.IO.StreamReader(filePath, System.Text.Encoding.UTF8);
            System.Text.StringBuilder buf = new System.Text.StringBuilder();
            char[] cbuf = new char[4096];
            int idx = 0;

            while ((idx = reader.Read((System.Char[]) cbuf, 0, cbuf.Length)) > 1)
            {
                buf.Append(cbuf, 0, idx);
            }
            json = new JSONObject(buf.ToString());

            reader.Close();
        }
开发者ID:hyunjong-lee,项目名称:NHanNanum,代码行数:20,代码来源:JSONReader.cs

示例7: Main

        public static new void Main(System.String[] args)
        {
            if (args.Length != 1)
            {
                System.Console.Out.WriteLine("Usage: DefaultXMLParser pipe_encoded_file");
                System.Environment.Exit(1);
            }

            //read and parse message from file
            try
            {
                System.IO.FileInfo messageFile = new System.IO.FileInfo(args[0]);
                long fileLength = SupportClass.FileLength(messageFile);
                //UPGRADE_TODO: Constructor 'java.io.FileReader.FileReader' was converted to 'System.IO.StreamReader' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073'"
                System.IO.StreamReader r = new System.IO.StreamReader(messageFile.FullName, System.Text.Encoding.Default);
                char[] cbuf = new char[(int) fileLength];
                //UPGRADE_TODO: Method 'java.io.Reader.read' was converted to 'System.IO.StreamReader.Read' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaioReaderread_char[]'"
                System.Console.Out.WriteLine("Reading message file ... " + r.Read((System.Char[]) cbuf, 0, cbuf.Length) + " of " + fileLength + " chars");
                r.Close();
                System.String messString = System.Convert.ToString(cbuf);

                Parser inParser = null;
                Parser outParser = null;
                PipeParser pp = new PipeParser();
                ca.uhn.hl7v2.parser.XMLParser xp = new DefaultXMLParser();
                System.Console.Out.WriteLine("Encoding: " + pp.getEncoding(messString));
                if (pp.getEncoding(messString) != null)
                {
                    inParser = pp;
                    outParser = xp;
                }
                else if (xp.getEncoding(messString) != null)
                {
                    inParser = xp;
                    outParser = pp;
                }

                Message mess = inParser.parse(messString);
                System.Console.Out.WriteLine("Got message of type " + mess.GetType().FullName);

                System.String otherEncoding = outParser.encode(mess);
                System.Console.Out.WriteLine(otherEncoding);
            }
            catch (System.Exception e)
            {
                SupportClass.WriteStackTrace(e, Console.Error);
            }
        }
开发者ID:snosrap,项目名称:nhapi,代码行数:48,代码来源:DefaultXMLParser.cs

示例8: myPerfTest

 //[InlineData(100)]
 public static void myPerfTest(int iterations)
 {
     foreach (var iteration in Benchmark.Iterations)
     {
         using (iteration.StartMeasurement())
         {
             for (int i = 0; i < iterations; i++)
             {
                 using (System.IO.StreamReader a = new System.IO.StreamReader(@"D:\PerfUnitTest\log2.txt"))
                 {
                     a.Read();
                 }
             }
         }
     }
 }
开发者ID:visia,项目名称:xunit-performance,代码行数:17,代码来源:ConsumptionTests.cs

示例9: getProfile

		/// <summary> Retrieves profile from persistent storage (by ID).  Returns null
		/// if the profile isn't found.
		/// </summary>
		public virtual System.String getProfile(System.String ID)
		{
			System.String profile = null;
			
			System.IO.FileInfo source = new System.IO.FileInfo(getFileName(ID));
			if (System.IO.File.Exists(source.FullName))
			{
				System.IO.StreamReader in_Renamed = new System.IO.StreamReader(new System.IO.StreamReader(source.FullName, System.Text.Encoding.Default).BaseStream, new System.IO.StreamReader(source.FullName, System.Text.Encoding.Default).CurrentEncoding);
				char[] buf = new char[(int) SupportClass.FileLength(source)];
				int check = in_Renamed.Read(buf, 0, buf.Length);
				in_Renamed.Close();
				if (check != buf.Length)
					throw new System.IO.IOException("Only read " + check + " of " + buf.Length + " bytes of file " + source.FullName);
				profile = new System.String(buf);
			}
			return profile;
		}
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:20,代码来源:FileProfileStore.cs

示例10: Main

        public static new void Main(System.String[] args)
        {
            if (args.Length != 1)
            {
                System.Console.Out.WriteLine("Usage: DefaultXMLParser pipe_encoded_file");
                System.Environment.Exit(1);
            }

            //read and parse message from file
            try
            {
                System.IO.FileInfo messageFile = new System.IO.FileInfo(args[0]);
                long fileLength = SupportClass.FileLength(messageFile);
                System.IO.StreamReader r = new System.IO.StreamReader(messageFile.FullName, System.Text.Encoding.Default);
                char[] cbuf = new char[(int)fileLength];
                System.Console.Out.WriteLine("Reading message file ... " + r.Read((System.Char[])cbuf, 0, cbuf.Length) + " of " + fileLength + " chars");
                r.Close();
                System.String messString = System.Convert.ToString(cbuf);

                ParserBase inParser = null;
                ParserBase outParser = null;
                PipeParser pp = new PipeParser();
                NHapi.Base.Parser.XMLParser xp = new DefaultXMLParser();
                System.Console.Out.WriteLine("Encoding: " + pp.GetEncoding(messString));
                if (pp.GetEncoding(messString) != null)
                {
                    inParser = pp;
                    outParser = xp;
                }
                else if (xp.GetEncoding(messString) != null)
                {
                    inParser = xp;
                    outParser = pp;
                }

                IMessage mess = inParser.Parse(messString);
                System.Console.Out.WriteLine("Got message of type " + mess.GetType().FullName);

                System.String otherEncoding = outParser.Encode(mess);
                System.Console.Out.WriteLine(otherEncoding);
            }
            catch (System.Exception e)
            {
                SupportClass.WriteStackTrace(e, Console.Error);
            }
        }
开发者ID:snosrap,项目名称:nhapi,代码行数:46,代码来源:DefaultXMLParser.cs

示例11: read

		/// <summary> Reads HL7 messages from an InputStream and outputs an array of HL7 message strings
		/// 
		/// </summary>
		/// <version>  $Revision: 1.1 $ updated on $Date: 2006/02/01 18:17:57 $ by $Author: nacharya $
		/// </version>
		public static System.String[] read(System.IO.Stream theMsgInputStream)
		{
			Parser hapiParser = new PipeParser();
			
			System.IO.StreamReader in_Renamed = new System.IO.StreamReader(new CommentFilterReader(new System.IO.StreamReader(theMsgInputStream, System.Text.Encoding.Default)).BaseStream, new CommentFilterReader(new System.IO.StreamReader(theMsgInputStream, System.Text.Encoding.Default)).CurrentEncoding);
			
			System.Text.StringBuilder rawMsgBuffer = new System.Text.StringBuilder();
			
			int c = 0;
			while ((c = in_Renamed.Read()) >= 0)
			{
				rawMsgBuffer.Append((char) c);
			}
			
			System.String[] messages = getHL7Messages(rawMsgBuffer.ToString());
			
			return messages;
		}
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:23,代码来源:NuGenHl7InputStreamReader.cs

示例12: readFile

		public static System.String readFile(System.String filename)
		{
			System.String readString = "";
			System.String tmp;
			
			System.IO.FileInfo f = new System.IO.FileInfo(filename);
			char[] readIn = new char[(int) (SupportClass.FileLength(f))];
			
			//UPGRADE_TODO: Expected value of parameters of constructor 'java.io.BufferedReader.BufferedReader' are different in the equivalent in .NET. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1092"'
			System.IO.StreamReader in_Renamed = new System.IO.StreamReader(new System.IO.StreamReader(f.FullName).BaseStream, System.Text.Encoding.UTF7);
			
			//UPGRADE_TODO: Method 'java.io.Reader.read' was converted to 'System.IO.StreamReader.Read' which has a different behavior. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1073_javaioReaderread_char[]"'
			in_Renamed.Read((System.Char[]) readIn, 0, readIn.Length);
			readString = new System.String(readIn);
			
			in_Renamed.Close();
			
			return readString;
		}
开发者ID:jiangguang5201314,项目名称:VMukti,代码行数:19,代码来源:FileUtility.cs

示例13: getRandom

 public static string getRandom(string fileName)
 {
     System.IO.FileStream stream=System.IO.File.OpenRead(fileName);
     System.IO.StreamReader reader=new System.IO.StreamReader(stream);
     Random rand = new Random(Environment.TickCount);
     long pos=(long)(rand.NextDouble()*(stream.Length - bufSize));
     stream.Seek(pos, System.IO.SeekOrigin.Begin);
     char[] buf=new char[3];
     reader.Read(buf, 0, 3);
     long i = 0;
     while ((buf[i] >> 14)==10 &&  ++i < buf.Length) ;
     stream.Seek(pos + i, System.IO.SeekOrigin.Begin);
     string str = "";
     for (int k = 0; k < 5; k++)
     {
         str += reader.ReadLine()+"\n";
     }
     return str;
 }
开发者ID:easai,项目名称:CountDown,代码行数:19,代码来源:CountDownFile.cs

示例14: getProfile

		/// <summary>Retrieves profile from persistent storage (by ID).</summary>
		public virtual System.String getProfile(System.String ID)
		{
			System.String profile = null;
			try
			{
				System.IO.StreamReader in_Renamed = new System.IO.StreamReader(new System.IO.StreamReader(System.Net.WebRequest.Create(getURL(ID)).GetResponse().GetResponseStream(), System.Text.Encoding.Default).BaseStream, new System.IO.StreamReader(System.Net.WebRequest.Create(getURL(ID)).GetResponse().GetResponseStream(), System.Text.Encoding.Default).CurrentEncoding);
				System.Text.StringBuilder buf = new System.Text.StringBuilder();
				int c = - 1;
				while ((c = in_Renamed.Read()) != - 1)
				{
					buf.Append((char) c);
				}
				in_Renamed.Close();
				profile = buf.ToString();
			}
			catch (System.UriFormatException e)
			{
				throw new System.IO.IOException("MalformedURLException: " + e.Message);
			}
			return profile;
		}
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:22,代码来源:URLProfileStore.cs

示例15: readFile

        public static System.String readFile(System.String filename)
        {
            System.String readString = "";
            //System.String tmp;

            System.IO.FileInfo f = new System.IO.FileInfo(filename);
            char[] readIn = new char[(int) ((long) SupportClass.FileLength(f))];

            //UPGRADE_TODO: The differences in the expected value  of parameters for constructor 'java.io.BufferedReader.BufferedReader'  may cause compilation errors.  "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1092'"
            //UPGRADE_WARNING: At least one expression was used more than once in the target code. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1181'"
            //UPGRADE_TODO: Constructor 'java.io.FileReader.FileReader' was converted to 'System.IO.StreamReader' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073'"
            System.IO.StreamReader in_Renamed = new System.IO.StreamReader(new System.IO.StreamReader(f.FullName, System.Text.Encoding.Default).BaseStream, new System.IO.StreamReader(f.FullName, System.Text.Encoding.Default).CurrentEncoding);

            //UPGRADE_TODO: Method 'java.io.Reader.read' was converted to 'System.IO.StreamReader.Read' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaioReaderread_char[]'"
            in_Renamed.Read((System.Char[]) readIn, 0, readIn.Length);
            readString = new System.String(readIn);

            in_Renamed.Close();

            return readString;
        }
开发者ID:altliu,项目名称:sandbox-aliu,代码行数:21,代码来源:FileUtility.cs


注:本文中的System.IO.StreamReader.Read方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。