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


C# System.IO.BinaryReader.ReadString方法代码示例

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


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

示例1: Load

        public static void Load()
        {
            IO.Log.Write("    Loading CampaingProgresss...");
            levelsCompleted.Clear();

            System.IO.BinaryReader br = new System.IO.BinaryReader(new System.IO.FileStream("Saves/progress.lpg",
                System.IO.FileMode.Open));

            String s = "";
            int l = 0;
            while (br.PeekChar() > -1)
            {
                s = br.ReadString();
                l = br.ReadInt32();
                byte[] d = new byte[l];
                for (int j = 0; j < l; j++)
                {
                    d[j] = br.ReadByte();
                }
                levelsCompleted.Add(s, d);
            }

            br.Close();
            IO.Log.Write("    Loading complete");
        }
开发者ID:XZelnar,项目名称:MicroWorld,代码行数:25,代码来源:CampaingProgress.cs

示例2: Deserialize

 public static BaseMetaObject Deserialize(FrontendBase fb, byte[] chunkID, byte[] buffer)
 {
     using (System.IO.MemoryStream MS = new System.IO.MemoryStream (buffer)) {
         using (System.IO.BinaryReader BR = new System.IO.BinaryReader (MS)) {
             return new Table (fb, chunkID, BR.ReadString ());
         }
     }
 }
开发者ID:vebin,项目名称:BD2,代码行数:8,代码来源:Table.cs

示例3: Deserialize

 public static Table Deserialize(byte[] bytes)
 {
     using (System.IO.MemoryStream MS = new System.IO.MemoryStream (bytes, false)) {
         using (System.IO.BinaryReader BR = new System.IO.BinaryReader (MS)) {
             return new Table (new Guid (BR.ReadBytes (16)), BR.ReadString ());
         }
     }
 }
开发者ID:vebin,项目名称:BD2,代码行数:8,代码来源:Table.cs

示例4: Deserialize

 public static ServiceParameters Deserialize(byte[] bytes)
 {
     string connectionString;
     using (System.IO.MemoryStream MS =  new System.IO.MemoryStream (bytes,false)) {
         using (System.IO.BinaryReader BR = new System.IO.BinaryReader (MS,System.Text.Encoding.Unicode)) {
             connectionString = BR.ReadString ();
         }
     }
     return new ServiceParameters (connectionString);
 }
开发者ID:vebin,项目名称:BD2,代码行数:10,代码来源:ServiceParameters.cs

示例5: Read

		public static ZipFile Read ( System.IO.Stream stream ) {
			ZipFile file = new ZipFile();

			var reader = new System.IO.BinaryReader ( stream );
			int count = reader.ReadInt32 ();
			for ( int i = 0; i < count; i++ ) {
				var name = reader.ReadString();
				var length = reader.ReadInt32 ();
				var bytes = reader.ReadBytes (length);

				file.dict[name] = new ZipEntry(name, bytes);
			}

			return file;
		}
开发者ID:JtheSpaceC,项目名称:Breaking-The-Rules,代码行数:15,代码来源:SimpleZipReplacement.cs

示例6: Deserialize

 public static ForeignKeyRelation Deserialize(byte[] bytes)
 {
     string name;
     int count;
     Guid[] childColumns;
     Guid[] parentColumns;
     using (System.IO.MemoryStream MS = new System.IO.MemoryStream (bytes, false)) {
         using (System.IO.BinaryReader BR = new System.IO.BinaryReader (MS)) {
             name = BR.ReadString ();
             count = BR.ReadInt32 ();
             childColumns = new Guid[count];
             parentColumns = new Guid[count];
             for (int n = 0; n != count; n++) {
                 childColumns [n] = new Guid (BR.ReadBytes (16));
                 parentColumns [n] = new Guid (BR.ReadBytes (16));
             }
         }
     }
     return new ForeignKeyRelation (name, childColumns, parentColumns);
 }
开发者ID:vebin,项目名称:BD2,代码行数:20,代码来源:ForeignKeyRelation.cs

示例7: importTilesetBtn_Click

        private void importTilesetBtn_Click(object sender, EventArgs e)
        {
            getFiles();

            if (GFXFile == null) return;
            if (PalFile == null) return;
            if (LayoutFile == null) return;

            OpenFileDialog ofd = new OpenFileDialog();
            ofd.Filter = LanguageManager.Get("Filters", "background");
            ofd.CheckFileExists = true;

            if (ofd.ShowDialog() != DialogResult.OK) return;

            System.IO.BinaryReader br = new System.IO.BinaryReader(
                new System.IO.FileStream(ofd.FileName, System.IO.FileMode.Open, System.IO.FileAccess.Read));
            string header = br.ReadString();
            if (header != fileHeader)
            {
                MessageBox.Show(
                    LanguageManager.Get("NSMBLevel", "InvalidFile"),
                    LanguageManager.Get("NSMBLevel", "Unreadable"),
                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            readFileContents(GFXFile, br);
            readFileContents(PalFile, br);
            readFileContents(LayoutFile, br);
            br.Close();
        }
开发者ID:MCGlux,项目名称:NSMB-Editor,代码行数:30,代码来源:BackgroundList.cs

示例8: Deserialize

 public static Column Deserialize(byte[] bytes)
 {
     using (System.IO.MemoryStream MS = new System.IO.MemoryStream (bytes, false)) {
         using (System.IO.BinaryReader BR = new System.IO.BinaryReader (MS)) {
             return new Column (new Guid (BR.ReadBytes (16)), BR.ReadString (), BR.ReadBoolean (), BR.ReadInt64 (), BR.ReadString ());
         }
     }
 }
开发者ID:vebin,项目名称:BD2,代码行数:8,代码来源:Column.cs

示例9: Deserialzie

 public static ChunkHeaderv1 Deserialzie(byte[] buffer)
 {
     if (buffer == null)
         throw new ArgumentNullException ("buffer");
     using (System.IO.MemoryStream MS = new System.IO.MemoryStream (buffer)) {
         using (System.IO.BinaryReader BR = new System.IO.BinaryReader (MS)) {
             return new ChunkHeaderv1 (DateTime.FromBinary (BR.ReadInt64 ()), BR.ReadString ());
         }
     }
 }
开发者ID:vebin,项目名称:BD2,代码行数:10,代码来源:ChunkHeader.cs

示例10: ReadBackupFilename

        /// <summary>
        /// Reads the name of the backup file used to create the catalog.
        /// </summary>
        public static string ReadBackupFilename(string Filename)
        {
            // Open the file
            System.IO.BinaryReader file = new System.IO.BinaryReader(new System.IO.FileStream(Filename, System.IO.FileMode.Open, System.IO.FileAccess.Read));

            // Read backup file name
            string bkfname = file.ReadString();

            // Close the file
            file.Close();

            return bkfname;
        }
开发者ID:340211173,项目名称:hf-2011,代码行数:16,代码来源:CCatalog.cs

示例11: LoadGroupObject

        private void LoadGroupObject(BinaryReader reader, int key, Dictionary<int, object> objects)
        {
            var comparer = ObjectReferenceEqualityComparer<object>.Default;

            int typeKey = reader.ReadInt32();
            if (typeKey == 0)
            {
                // this is a string, nothing more to load
                reader.ReadString();
                return;
            }

            string typeName = (string)objects[typeKey];
            if (typeName == typeof(bool).FullName)
            {
                // nothing more to load
                reader.ReadBoolean();
                return;
            }
            else if (typeName == typeof(TemplateToken).FullName || typeName == typeof(CommonToken).FullName)
            {
                // nothing more to load
                int channel = reader.ReadInt32();
                int charPositionInLine = reader.ReadInt32();
                int line = reader.ReadInt32();
                int startIndex = reader.ReadInt32();
                int stopIndex = reader.ReadInt32();
                string text = reader.ReadString();
                int tokenIndex = reader.ReadInt32();
                int type = reader.ReadInt32();
                return;
            }
            else if (typeName == typeof(CompiledTemplate).FullName)
            {
                CompiledTemplate compiledTemplate = (CompiledTemplate)objects[key];
                string name = reader.ReadString();
                string prefix = reader.ReadString();
                string template = reader.ReadString();
                int templateDefStartTokenObject = reader.ReadInt32();
                bool hasFormalArgs = reader.ReadBoolean();
                int nativeGroupObject = reader.ReadInt32();
                bool isRegion = reader.ReadBoolean();
                Template.RegionType regionDefType = (Template.RegionType)reader.ReadInt32();
                bool isAnonSubtemplate = reader.ReadBoolean();

                compiledTemplate.TemplateDefStartToken = (IToken)objects[templateDefStartTokenObject];
                compiledTemplate.NativeGroup = this;

                int formalArgsLength = reader.ReadInt32();
                if (formalArgsLength >= 0)
                {
                    List<FormalArgument> formalArguments = new List<FormalArgument>(formalArgsLength);

                    for (int i = 0; i < formalArgsLength; i++)
                    {
                        int formalArgObject = reader.ReadInt32();
                        formalArguments.Add((FormalArgument)objects[formalArgObject]);
                    }

                    compiledTemplate.FormalArguments = formalArguments;
                }

                int stringsLength = reader.ReadInt32();
                for (int i = 0; i < stringsLength; i++)
                    reader.ReadString();

                int instrsLength = reader.ReadInt32();
                if (instrsLength >= 0)
                    reader.ReadBytes(instrsLength);

                int codeSize = reader.ReadInt32();

                int sourceMapLength = reader.ReadInt32();
                for (int i = 0; i < sourceMapLength; i++)
                {
                    int start = reader.ReadInt32();
                    int length = reader.ReadInt32();
                }

                return;
            }
            else if (typeName == typeof(FormalArgument).FullName)
            {
                FormalArgument formalArgument = (FormalArgument)objects[key];
                string name = reader.ReadString();
                int index = reader.ReadInt32();
                IToken defaultValueToken = (IToken)objects[reader.ReadInt32()];
                int defaultValueObject = reader.ReadInt32();
                int compiledDefaultValue = reader.ReadInt32();

                formalArgument.DefaultValue = objects[defaultValueObject];
                formalArgument.CompiledDefaultValue = (CompiledTemplate)objects[compiledDefaultValue];
            }
            else if (typeName == typeof(Template).FullName)
            {
                Template template = (Template)objects[key];

                int implObject = reader.ReadInt32();
                template.impl = (CompiledTemplate)objects[implObject];

//.........这里部分代码省略.........
开发者ID:mahanteshck,项目名称:antlrcs,代码行数:101,代码来源:TemplateGroup.cs

示例12: Read_pachm

            /// <summary>
            /// reads a file and populates the map receiver instance.
            /// </summary>
            /// <returns></returns>
            public static bool Read_pachm(out Mapping.PachMapReceiver[] Map)
            {
                System.Windows.Forms.OpenFileDialog of = new System.Windows.Forms.OpenFileDialog();
                of.DefaultExt = ".pachm";
                of.AddExtension = true;
                of.Filter = "Pachyderm Mapping Data File (*.pachm)|*.pachm|" + "All Files|";
                if (of.ShowDialog() != System.Windows.Forms.DialogResult.OK)
                {
                    Map = null;
                    return false;
                }
                System.IO.BinaryReader sr = new System.IO.BinaryReader(System.IO.File.Open(of.FileName, System.IO.FileMode.Open));
                //1. Write calculation type. (string)
                string CalcType = sr.ReadString();
                if (CalcType != "Type;Map_Data" && CalcType != "Type;Map_Data_NoDir") throw new Exception("Map Data File Expected");
                bool Directional = (CalcType == "Type;Map_Data");

                //2. Write the number of samples in each histogram. (int)
                int SampleCT = (int)sr.ReadUInt32();
                //3. Write the sample rate. (int)
                int SampleRate = (int)sr.ReadUInt32();
                //4. Write the number of Receivers (int)
                int Rec_CT = (int)sr.ReadUInt32();
                //4.5 Write the version number
                double version = 1.1;
                double rev = 0;
                //5. Announce that the following data pertains to the form of the analysis mesh. (string)
                int s_ct=1;
                Rhino.Geometry.Mesh Map_Mesh = new Rhino.Geometry.Mesh();
                Map = new Mapping.PachMapReceiver[1];
                //Map[0] = new Pach_Map_Receiver();
                //double[] Rho_C = null;
                double[] delay;

                do
                {
                    switch (sr.ReadString())
                    {
                        case "Version":
                            //Pach1.7 = Versioning functionality added.
                            string v = sr.ReadString();
                            version = double.Parse(v.Substring(0, 3));
                            rev = int.Parse(v.Split(new char[1] { '.' })[3]);
                            break;
                        case "Mesh Information":
                            //6. Announce Mesh Vertices (string)
                            //Write the number of vertices & faces (int) (int)
                            if (sr.ReadString() != "Mesh Vertices") throw new Exception("Mesh Vertices Expected");

                            int VC = (int)sr.ReadUInt32();
                            int FC = (int)sr.ReadUInt32();
                            for (int i = 0; i < VC; i++)
                            {
                                //Write Vertex: (double) (double) (double)
                                Map_Mesh.Vertices.Add(new Rhino.Geometry.Point3d(sr.ReadSingle(), sr.ReadSingle(), sr.ReadSingle()));
                            }

                            //7. Announce Mesh Faces (string)
                            if (sr.ReadString() != "Mesh Faces") throw new Exception("Mesh Faces Expected");

                            for (int i = 0; i < FC; i++)
                            {
                                // Write mesh vertex indices: (int) (int) (int) (int)
                                Map_Mesh.Faces.AddFace((int)sr.ReadUInt32(), (int)sr.ReadUInt32(), (int)sr.ReadUInt32(), (int)sr.ReadUInt32());
                            }
                            break;
                        case "Sources":
                            //7.5: Announce the number of sources.
                            s_ct = sr.ReadInt32();
                            delay = new double[s_ct];
                            Map = new Mapping.PachMapReceiver[s_ct];
                            //7.5a Announce the type of source.

                            for (int s = 0; s < s_ct; s++)
                            {
                                Map[s] = new Mapping.PachMapReceiver();
                                Map[s].CutOffTime = (double)SampleCT / (double)SampleRate;
                                Map[s].SampleCT = SampleCT;
                                Map[s].SampleRate = SampleRate;
                                Map[s].Map_Mesh = Map_Mesh;
                                Map[s].Rec_List = new Mapping.PachMapReceiver.Map_Receiver[Rec_CT];
                                Map[s].SrcType = sr.ReadString();
                                //4.4 Source delay (ms)
                                if (version > 2.0 || (version == 2.0 && rev >= 1))
                                {
                                    delay[s] = sr.ReadDouble();
                                }
                            }
                            break;
                        case "SourceswLoc":
                            //7.5: Announce the number of sources.
                            s_ct = sr.ReadInt32();
                            delay = new double[s_ct];
                            Map = new Mapping.PachMapReceiver[s_ct];
                            //7.5a Announce the type of source.

//.........这里部分代码省略.........
开发者ID:philrob22,项目名称:PachydermAcoustic_Rhinoceros,代码行数:101,代码来源:Classes_IO.cs

示例13: connect

        public void connect()
        {
            Program.Log("connect");
            NetworkStream myClientStream;

               while (!terminate)
            {
               TcpClient server = new TcpClient();

               IPEndPoint serverEndPoint = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 3000);

               Program.Log("Attempting to connect to " + serverEndPoint.Address.ToString() + "on port number " + serverEndPoint.Port.ToString());
                int sleepTime = 5; // זמן המתנה בין נסיונות התחברות - נתחיל ב 5  שנייה
            #region CONNECT
                do
                {
                    try
                    {
                        Program.Log("Attempting to connect ...");
                        server.Connect(serverEndPoint);
                    }
                    catch (Exception e)
                    {
                        Program.Log("connect threw: " + e.Message);
                        Program.Log("sleeping " + sleepTime + " sec ...");
                        System.Threading.Thread.Sleep(sleepTime * 1000);
                        if (sleepTime < 60 * 10) // הכי הרבה נמתין 10 דקות
                        {
                            sleepTime += 10;
                        }
                    }
                } while (!terminate && !server.Connected); // עד שנתחבר או שהורו למטלה לעצור
            #endregion

                Program.Log("I am connected to " + IPAddress.Parse(((IPEndPoint)server.Client.RemoteEndPoint).Address.ToString()) + "on port number " + ((IPEndPoint)server.Client.RemoteEndPoint).Port.ToString());

                // Using the LocalEndPoint property.
                Program.Log("My local IpAddress is :" + IPAddress.Parse(((IPEndPoint)server.Client.LocalEndPoint).Address.ToString()) + "I am connected on port number " + ((IPEndPoint)server.Client.LocalEndPoint).Port.ToString());
                myClientStream = server.GetStream();
                if (myClientStream.CanWrite && myClientStream.CanRead)
            #region READ

               {
                    myClientWriter = new System.IO.BinaryWriter(myClientStream);
                    myClientReader = new System.IO.BinaryReader(myClientStream);
                    // Point point;
                    string tempString = "";
                    reconnect = false;
                    do
                    {
                        //                   if (myClientStream.DataAvailable)
                        {
                            Program.Log("reading ...");
                            try { tempString = myClientReader.ReadString(); }
                            catch (Exception e)
                            {
                                Program.Log("ReadString threw: " + e.Message);
                                reconnect = true;
                                continue;
                            }
                            Program.Log("request is " + tempString);
                            string[] items = tempString.Split('#');
                            try
                            {
                                switch (items[0])
                                {
                                    case THComm.Tokens.TestRequest:
                                        Program.Log("Port" + ((IPEndPoint)server.Client.LocalEndPoint).Port.ToString() + " got Test");
                                        for (int i = 10; i < 101; i += 10)
                                        {
                                            myClientWriter.Write(THComm.Tokens.Progress);
                                            myClientWriter.Write(i);
                                            Console.Write(" ... " + i);
                                            System.Threading.Thread.Sleep(100);
                                        }
                                        Console.WriteLine();
                                        break;
                                    case THComm.Tokens.ScreenCapRequest:
                                        {
                                            Program.Log("Port" + ((IPEndPoint)server.Client.LocalEndPoint).Port.ToString() + " got ScreenCap");
                                            THDevice.Device sc = new THDevice.ScreenCap();
                                            byte[] data = sc.GetData();
                                            Program.Log("Port" + ((IPEndPoint)server.Client.LocalEndPoint).Port.ToString() + " acquired ScreenCap length=" + data.Length.ToString());

                                            myClientWriter.Write(THComm.Tokens.Data);
                                            myClientWriter.Write(data.Length);
                                            myClientWriter.Write(data);
                                            Program.Log("Port" + ((IPEndPoint)server.Client.LocalEndPoint).Port.ToString() + " sent ScreenCap ");
                                        }
                                        break;
                                    case THComm.Tokens.CamCapRequest:
                                        {
                                            Program.Log("Port" + ((IPEndPoint)server.Client.LocalEndPoint).Port.ToString() + " got CamCap");
                                            THDevice.Device device = new THDevice.WebCam();
                                            byte[] data = device.GetData();
                                            myClientWriter.Write(THComm.Tokens.Data);
                                            myClientWriter.Write(data.Length);
                                            myClientWriter.Write(data);

                                        }
//.........这里部分代码省略.........
开发者ID:springcomet,项目名称:Trojan,代码行数:101,代码来源:Client.cs

示例14: Deserialize

 public static ObjectBusMessage Deserialize(byte[] bytes)
 {
     using (System.IO.MemoryStream MS = new System.IO.MemoryStream (bytes, false)) {
         using (System.IO.BinaryReader BR = new System.IO.BinaryReader (MS)) {
             return new FileShareMessage (BR.ReadString (), new Guid (BR.ReadBytes (16)));
         }
     }
 }
开发者ID:vebin,项目名称:BD2,代码行数:8,代码来源:FileShareMessage.cs

示例15: OnServerInformationReceived

        void OnServerInformationReceived(byte[] data)
        {
            using (System.IO.MemoryStream readStream = new System.IO.MemoryStream(data))
            {
                using (System.IO.BinaryReader reader = new System.IO.BinaryReader(readStream))
                {
                    ServerPeer.name = reader.ReadString();

                    int peerCount = reader.ReadInt32();
                    for (int i = 0; i < peerCount; ++i)
                    {
                        string address = reader.ReadString();
                        int port = reader.ReadInt32();
                        string username = reader.ReadString();

                        Peer peer = new Peer(new IPEndPoint(IPAddress.Parse(address), port), true);
                        peer.name = username;

                        using (System.IO.MemoryStream writeStream = new System.IO.MemoryStream())
                        {
                            using (System.IO.BinaryWriter writer = new System.IO.BinaryWriter(writeStream))
                            {
                                writer.Write(CurrentUser);
                                peer.SendData(P2PNotices.PeerConnect, writeStream.ToArray());
                            }
                        }

                        peer.isLoggedIn = true;
                        peer.isConnected = true;
                        peersToAdd.Add(peer);
                    }
                }
            }

            if (JoinedGame != null)
                JoinedGame(this, peers.Union(peersToAdd).ToList());
        }
开发者ID:ptsoccer,项目名称:P2PGame,代码行数:37,代码来源:P2PNetClass.cs


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