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


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

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


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

示例1: Load

        public bool Load(string path)
        {
            System.IO.FileStream fs = null;
            try
            {
                fs = System.IO.File.Open(path, System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.Read);
            }
            catch(System.IO.FileNotFoundException e)
            {
                return false;
            }

            var br = new System.IO.BinaryReader(fs);

            var buf = new byte[1024];

            if (br.Read(buf, 0, 8) != 8)
            {
                fs.Dispose();
                br.Dispose();
                return false;
            }

            // png Header 89 50 4E 47 0D 0A 1A 0A
            if (buf[0] == 0x89 &&
                buf[1] == 0x50 &&
                buf[2] == 0x4E &&
                buf[3] == 0x47 &&
                buf[4] == 0x0D &&
                buf[5] == 0x0A &&
                buf[6] == 0x1A &&
                buf[7] == 0x0A)
            {
                if (br.Read(buf, 0, 25) != 25)
                {
                    fs.Dispose();
                    br.Dispose();
                    return false;
                }

                var width = new byte[] { buf[11], buf[10], buf[9], buf[8] };
                var height = new byte[] { buf[15], buf[14], buf[13], buf[12] };
                Width = BitConverter.ToInt32(width, 0);
                Height = BitConverter.ToInt32(height, 0);
            }
            else
            {
                fs.Dispose();
                br.Dispose();
                return false;
            }

            fs.Dispose();
            br.Dispose();
            return true;
        }
开发者ID:kou-yeung,项目名称:Effekseer,代码行数:56,代码来源:TextureInformation.cs

示例2: filAddExtension_Upload

		protected void filAddExtension_Upload(object sender, FileUploadEventArgs e)
		{
			//get the uploaded file and its metadata
			HttpPostedFile postedFile = e.PostedFile;
			string filepath = postedFile.FileName;
			string filename = filepath.Substring(filepath.LastIndexOf('\\') + 1);

			if (ValidateFile(filename))
			{
				//separate the file extension from the filename
				string fileExt = System.IO.Path.GetExtension(filename);
				string fileNameWithoutExt = System.IO.Path.GetFileNameWithoutExtension(filename);

				int contentLength = postedFile.ContentLength;
				string contentType = postedFile.ContentType;

				System.IO.BinaryReader reader = new System.IO.BinaryReader(postedFile.InputStream);
				byte[] bytes = new byte[contentLength];
				reader.Read(bytes, 0, contentLength);

				//store the file into the data store
				Utility.DocumentStorage documentStorageObject = Utility.DocumentStorage.GetDocumentStorageObject(_itatSystem.DocumentStorageType);
				documentStorageObject.RootPath = _itatSystem.DocumentStorageRootPath;
				string objectId = documentStorageObject.SaveDocument(fileNameWithoutExt, fileExt, bytes);

				//add metadata about the extension to the template object
				Business.Extension extension = new Kindred.Knect.ITAT.Business.Extension();
				extension.FileName = filename;
				extension.ObjectID = objectId;
				_template.Extensions.Add(extension);

				//update the form
				InitializeForm(_template.Extensions.Count - 1);  //select newly added row (last row in the grid)
			}
		}
开发者ID:dlnuckolls,项目名称:glorykidd-public,代码行数:35,代码来源:TemplateExtensions.aspx.cs

示例3: GetEmbeddedContentAsBinary

        public byte[] GetEmbeddedContentAsBinary(string defaultNamespace, string content)
        {
            string resourceName1 = content.Replace("/", ".");
            string resourceName2 = defaultNamespace + resourceName1;
            string resourceName3 = resourceName2.ToLower();
            string resourceName;
            if (!mapCaseInsensitiveToCaseSensitive.TryGetValue(resourceName3, out resourceName))
            {
                return null;
            }

            using (System.IO.Stream stream = this.assembly.GetManifestResourceStream(resourceName))
            using (var reader = new System.IO.BinaryReader(stream))
            {
                var result = new byte[stream.Length];
                reader.Read(result, 0, (int)stream.Length);
                return result;
            }
        }
开发者ID:NathanTeeuwen,项目名称:Dominulator,代码行数:19,代码来源:Resources.cs

示例4: Start

        public void Start(string InputFilename, string OutputFilename, UInt64 Key, DESMode.DESMode Mode, bool Decode)
        {
            using (System.IO.BinaryReader Reader = new System.IO.BinaryReader(System.IO.File.Open(InputFilename, System.IO.FileMode.Open)))
            {
                using (System.IO.BinaryWriter Writer = new System.IO.BinaryWriter(System.IO.File.Open(OutputFilename, System.IO.FileMode.OpenOrCreate)))
                {
                    const int MaxSize = 1048576;
                    int n = 0;
                    byte[] buffer = new byte[MaxSize];
                    int size = 0;
                    int k = 0;
                    UInt64 DESResult = 0;

                    while ((n = Reader.Read(buffer, 0, MaxSize)) > 0)
                    {
                        k = 0;
                        while (n > 0)
                        {
                            if ((n / 8) > 0)
                                size = 8;
                            else
                                size = n;
                            byte[] tempArray = new byte[size];
                            for (int i = 0; i != size; ++i, ++k)
                                tempArray[i] = buffer[k];

                            if (!Decode)
                                DESResult = Mode.EncodeBlock(GetUIntFromByteArray(tempArray), Key);
                            else
                                DESResult = Mode.DecodeBlock(GetUIntFromByteArray(tempArray), Key);
                            Writer.Write(GetByteArrayFromUInt(DESResult, size), 0, size);

                            n -= 8;
                        }
                    }
                    Writer.Close();
                }
                Reader.Close();
            }
        }
开发者ID:morozovcookie,项目名称:des,代码行数:40,代码来源:DES.cs

示例5: GenerateReport

        /// <summary>
        /// 生成报表
        /// </summary>
        /// <param name="reportInfoName"></param>
        /// <param name="dateStart"></param>
        /// <param name="dateEnd"></param>
        /// <returns></returns>
        public static byte[] GenerateReport(string reportInfoName, DateTime dateStart, DateTime dateEnd)
        {
            CrystalHelper crystalHelper = new CrystalHelper();

            ReportInfo reportInfo = ADInfoBll.Instance.GetReportInfo(reportInfoName);
            if (reportInfo == null)
            {
                throw new ArgumentException("不存在名为" + reportInfoName + "的ReportInfo!");
            }
            ReportDocument reportDocument = ReportHelper.CreateReportDocument(reportInfo.ReportDocument);
            crystalHelper.ReportSource = reportDocument;
            System.Data.DataSet templateDataSet = ReportHelper.CreateDataset(reportInfo.DatasetName);

            IList<ISearchManager> sms = new List<ISearchManager>();
            IList<ReportDataInfo> reportDataInfos = ADInfoBll.Instance.GetReportDataInfo(reportInfo.Name);
            foreach (ReportDataInfo reportDataInfo in reportDataInfos)
            {
                if (string.IsNullOrEmpty(reportDataInfo.SearchManagerClassName))
                {
                    throw new ArgumentException("ReportDataInfo of " + reportDataInfo.Name + " 's SearchManagerClassName must not be null!");
                }

                ISearchManager sm = ServiceProvider.GetService<IManagerFactory>().GenerateSearchManager(reportDataInfo.SearchManagerClassName, reportDataInfo.SearchManagerClassParams);

                sm.EnablePage = false;

                sms.Add(sm);
            }

            ISearchExpression se = SearchExpression.And(SearchExpression.Ge("日期", dateStart),
                SearchExpression.Le("日期", dateEnd));
            for (int i = 0; i < reportDataInfos.Count; ++i)
            {
                System.Collections.IEnumerable dataList = sms[i].GetData(se, null);

                string s = reportDataInfos[i].DatasetTableName;
                if (!templateDataSet.Tables.Contains(s))
                {
                    throw new ArgumentException("报表DataSet中未包含名为" + s + "的DataTable!");
                }
                System.Data.DataTable dt = templateDataSet.Tables[s];
                dt.Rows.Clear();
                GenerateReportData.Generate(dt, dataList, reportDataInfos[i].GridName);
            }

            // Set Parameter
            SetParameter(crystalHelper, se);

            crystalHelper.DataSource = templateDataSet;

            string fileName = System.IO.Path.GetTempFileName();
            crystalHelper.Export(fileName, CrystalExportFormat.PortableDocFormat);

            System.IO.FileStream fs = new System.IO.FileStream(fileName, System.IO.FileMode.Open, System.IO.FileAccess.Read);
            byte[] fileData = new byte[fs.Length];

            using (System.IO.BinaryReader sr = new System.IO.BinaryReader(fs))
            {
                sr.Read(fileData, 0, fileData.Length);
            }
            fs.Close();
            System.IO.File.Delete(fileName);

            return fileData;
        }
开发者ID:urmilaNominate,项目名称:mERP-framework,代码行数:72,代码来源:ReportGenerator.cs

示例6: ToArrays

    /// <summary>
    /// Imports a Galactic SPC file into a x and an y array. The file must not be a multi spectrum file (an exception is thrown in this case).
    /// </summary>
    /// <param name="xvalues">The x values of the spectrum.</param>
    /// <param name="yvalues">The y values of the spectrum.</param>
    /// <param name="filename">The filename where to import from.</param>
    /// <returns>Null if successful, otherwise an error description.</returns>
    public static string ToArrays(string filename, out double [] xvalues, out double [] yvalues)
    {
      System.IO.Stream stream=null;

      SPCHDR hdr = new SPCHDR();
      SUBHDR subhdr = new SUBHDR();

      try
      {
        stream = new System.IO.FileStream(filename,System.IO.FileMode.Open,System.IO.FileAccess.Read,System.IO.FileShare.Read);
        System.IO.BinaryReader binreader = new System.IO.BinaryReader(stream);


        hdr.ftflgs = binreader.ReadByte(); // ftflgs : not-evenly spaced data
        hdr.fversn = binreader.ReadByte(); // fversn : new version
        hdr.fexper = binreader.ReadByte(); // fexper : general experimental technique
        hdr.fexp   = binreader.ReadByte(); // fexp   : fractional scaling exponent (0x80 for floating point)

        hdr.fnpts  = binreader.ReadInt32(); // fnpts  : number of points

        hdr.ffirst = binreader.ReadDouble(); // ffirst : first x-value
        hdr.flast  = binreader.ReadDouble(); // flast : last x-value
        hdr.fnsub  = binreader.ReadInt32(); // fnsub : 1 (one) subfile only
      
        binreader.ReadByte(); //  Type of X axis units (see definitions below) 
        binreader.ReadByte(); //  Type of Y axis units (see definitions below) 
        binreader.ReadByte(); // Type of Z axis units (see definitions below)
        binreader.ReadByte(); // Posting disposition (see GRAMSDDE.H)

        binreader.Read(new byte[0x1E0],0,0x1E0); // rest of SPC header


        // ---------------------------------------------------------------------
        //   following the x-values array
        // ---------------------------------------------------------------------

        if(hdr.fversn!=0x4B)
        {
          if(hdr.fversn==0x4D)
            throw new System.FormatException(string.Format("This SPC file has the old format version of {0}, the only version supported here is the new version {1}",hdr.fversn,0x4B));
          else
            throw new System.FormatException(string.Format("This SPC file has a version of {0}, the only version recognized here is {1}",hdr.fversn,0x4B));
        }

        if(0!=(hdr.ftflgs & 0x80))
        {
          xvalues = new double[hdr.fnpts];
          for(int i=0;i<hdr.fnpts;i++)
            xvalues[i] = binreader.ReadSingle();
        }
        else if(0==hdr.ftflgs) // evenly spaced data
        {
          xvalues = new double[hdr.fnpts];
          for(int i=0;i<hdr.fnpts;i++)
            xvalues[i] = hdr.ffirst + i*(hdr.flast-hdr.ffirst)/(hdr.fnpts-1);
        }
        else
        {
          throw new System.FormatException("The SPC file must not be a multifile; only single file format is accepted!");
        }



        // ---------------------------------------------------------------------
        //   following the y SUBHEADER
        // ---------------------------------------------------------------------

        subhdr.subflgs = binreader.ReadByte(); // subflgs : always 0
        subhdr.subexp  = binreader.ReadByte(); // subexp : y-values scaling exponent (set to 0x80 means floating point representation)
        subhdr.subindx = binreader.ReadInt16(); // subindx :  Integer index number of trace subfile (0=first)

        subhdr.subtime = binreader.ReadSingle(); // subtime;   Floating time for trace (Z axis corrdinate) 
        subhdr.subnext = binreader.ReadSingle(); // subnext;   Floating time for next trace (May be same as beg) 
        subhdr.subnois = binreader.ReadSingle(); // subnois;   Floating peak pick noise level if high byte nonzero 

        subhdr.subnpts = binreader.ReadInt32(); // subnpts;  Integer number of subfile points for TXYXYS type 
        subhdr.subscan = binreader.ReadInt32(); // subscan; Integer number of co-added scans or 0 (for collect) 
        subhdr.subwlevel = binreader.ReadSingle();        // subwlevel;  Floating W axis value (if fwplanes non-zero) 
        subhdr.subresv   = binreader.ReadInt32(); // subresv[4];   Reserved area (must be set to zero) 


        // ---------------------------------------------------------------------
        //   following the y-values array
        // ---------------------------------------------------------------------
        yvalues = new double[hdr.fnpts];
        
        if(hdr.fexp==0x80) //floating point format
        {
          for(int i=0;i<hdr.fnpts;i++)
            yvalues[i] = binreader.ReadSingle();
        }
        else // fixed exponent format
        {
//.........这里部分代码省略.........
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:101,代码来源:ImportGalacticSpcFiles.cs

示例7: LoadTerrainFile

        public LevelTerrain LoadTerrainFile(System.IO.Stream stream)
        {
            System.IO.BinaryReader br = new System.IO.BinaryReader(stream);

            byte[] fileBuffer = new byte[stream.Length];
            br.Read(fileBuffer, 0, (int)stream.Length);

            LevelTerrain terrain = new LevelTerrain();
            Scale scales = new Scale();
            scales.Scales = new Vector3(10.0f, 1.0f, 10.0f);
            terrain.Scaling = scales;

            // assume square image
            int dim = (int)Math.Sqrt(stream.Length);
            terrain.HeightMapDimensions = new Point(dim, dim);
            terrain.HeightMap = fileBuffer;

            String name = "TERRAIN" + GetNextTerrainIdx();
            terrain.Name = name;
            return terrain;
        }
开发者ID:mailek,项目名称:sojourn_editor,代码行数:21,代码来源:LevelObjectData.cs

示例8: LoadFileData

        /// <summary>
        /// Loads the file data in binary format
        /// </summary>
        /// <param name="fileName">Name of the file.</param>
        /// <returns>Binary file data</returns>
        private static byte[] LoadFileData(string fileName)
        {
            byte[] data = null;

            using (System.IO.FileStream fStream = new System.IO.FileStream(fileName, System.IO.FileMode.Open, System.IO.FileAccess.Read))
            {
                using (System.IO.BinaryReader reader = new System.IO.BinaryReader(fStream))
                {
                    data = new byte[fStream.Length];
                    reader.Read(data, 0, data.Length);
                }
            }

            return data;
        }
开发者ID:jasper22,项目名称:ReadOpenSslKeys,代码行数:20,代码来源:ParserFactory.cs

示例9: Main

		public static void  Main(System.String[] args)
		{
			PorterStemmer s = new PorterStemmer();
			
			for (int i = 0; i < args.Length; i++)
			{
				try
				{
					System.IO.BinaryReader in_Renamed = new System.IO.BinaryReader(System.IO.File.Open(args[i], System.IO.FileMode.Open, System.IO.FileAccess.Read));
					byte[] buffer = new byte[1024];
					int bufferLen, offset, ch;
					
					bufferLen = in_Renamed.Read(buffer, 0, buffer.Length);
					offset = 0;
					s.Reset();
					
					while (true)
					{
						if (offset < bufferLen)
							ch = buffer[offset++];
						else
						{
							bufferLen = in_Renamed.Read(buffer, 0, buffer.Length);
							offset = 0;
							if (bufferLen <= 0)
								ch = - 1;
							else
								ch = buffer[offset++];
						}
						
						if (System.Char.IsLetter((char) ch))
						{
							s.Add(System.Char.ToLower((char) ch));
						}
						else
						{
							s.Stem();
							System.Console.Out.Write(s.ToString());
							s.Reset();
							if (ch < 0)
								break;
							else
							{
								System.Console.Out.Write((char) ch);
							}
						}
					}
					
					in_Renamed.Close();
				}
				catch (System.IO.IOException )
				{
					System.Console.Out.WriteLine("error reading " + args[i]);
				}
			}
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:56,代码来源:PorterStemmer.cs

示例10: DecodeRSAPublicKey

        /// <summary>
        /// Get a cryptographic service for encrypting data using the server's RSA public key
        /// </summary>
        /// <param name="key">Byte array containing the encoded key</param>
        /// <returns>Returns the corresponding RSA Crypto Service</returns>
        public static RSACryptoServiceProvider DecodeRSAPublicKey(byte[] x509key)
        {
            /* Code from StackOverflow no. 18091460 */

            byte[] SeqOID = { 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x01 };

            System.IO.MemoryStream ms = new System.IO.MemoryStream(x509key);
            System.IO.BinaryReader reader = new System.IO.BinaryReader(ms);

            if (reader.ReadByte() == 0x30)
                ReadASNLength(reader); //skip the size
            else
                return null;

            int identifierSize = 0; //total length of Object Identifier section
            if (reader.ReadByte() == 0x30)
                identifierSize = ReadASNLength(reader);
            else
                return null;

            if (reader.ReadByte() == 0x06) //is the next element an object identifier?
            {
                int oidLength = ReadASNLength(reader);
                byte[] oidBytes = new byte[oidLength];
                reader.Read(oidBytes, 0, oidBytes.Length);
                if (oidBytes.SequenceEqual(SeqOID) == false) //is the object identifier rsaEncryption PKCS#1?
                    return null;

                int remainingBytes = identifierSize - 2 - oidBytes.Length;
                reader.ReadBytes(remainingBytes);
            }

            if (reader.ReadByte() == 0x03) //is the next element a bit string?
            {
                ReadASNLength(reader); //skip the size
                reader.ReadByte(); //skip unused bits indicator
                if (reader.ReadByte() == 0x30)
                {
                    ReadASNLength(reader); //skip the size
                    if (reader.ReadByte() == 0x02) //is it an integer?
                    {
                        int modulusSize = ReadASNLength(reader);
                        byte[] modulus = new byte[modulusSize];
                        reader.Read(modulus, 0, modulus.Length);
                        if (modulus[0] == 0x00) //strip off the first byte if it's 0
                        {
                            byte[] tempModulus = new byte[modulus.Length - 1];
                            Array.Copy(modulus, 1, tempModulus, 0, modulus.Length - 1);
                            modulus = tempModulus;
                        }

                        if (reader.ReadByte() == 0x02) //is it an integer?
                        {
                            int exponentSize = ReadASNLength(reader);
                            byte[] exponent = new byte[exponentSize];
                            reader.Read(exponent, 0, exponent.Length);

                            RSACryptoServiceProvider RSA = new RSACryptoServiceProvider();
                            RSAParameters RSAKeyInfo = new RSAParameters();
                            RSAKeyInfo.Modulus = modulus;
                            RSAKeyInfo.Exponent = exponent;
                            RSA.ImportParameters(RSAKeyInfo);
                            return RSA;
                        }
                    }
                }
            }
            return null;
        }
开发者ID:Cecer1,项目名称:Minecraft-Console-Client,代码行数:74,代码来源:Crypto.cs

示例11: Load

 public static ActionLibrary Load(System.IO.Stream s)
 {
     ActionLibrary lib = new ActionLibrary();
     System.IO.BinaryReader br = new System.IO.BinaryReader(s, Encoding.ASCII);
     lib.GameMakerVersion = br.ReadInt32();
     bool gm5 = lib.GameMakerVersion == 500;
     lib.TabCaption = new string(br.ReadChars(br.ReadInt32()));
     lib.LibraryID = br.ReadInt32();
     lib.Author = new string(br.ReadChars(br.ReadInt32()));
     lib.Version = br.ReadInt32();
     lib.LastChanged = new DateTime(1899, 12, 30).AddDays(br.ReadDouble());
     lib.Info = new string(br.ReadChars(br.ReadInt32()));
     lib.InitializationCode = new string(br.ReadChars(br.ReadInt32()));
     lib.AdvancedModeOnly = br.ReadInt32() == 0 ? false : true;
     lib.ActionNumberIncremental = br.ReadInt32();
     for (int i = br.ReadInt32(); i > 0; i--)
     {
         int ver = br.ReadInt32();
         ActionDefinition a = new ActionDefinition(lib, new string(br.ReadChars(br.ReadInt32())), br.ReadInt32());
         a.GameMakerVersion = ver;
         int size = br.ReadInt32();
         a.OriginalImage = new byte[size];
         br.Read(a.OriginalImage, 0, size);
         System.IO.MemoryStream ms = new System.IO.MemoryStream(a.OriginalImage);
         System.Drawing.Bitmap b = (System.Drawing.Bitmap)System.Drawing.Bitmap.FromStream(ms);
         a.Image = new System.Drawing.Bitmap(24, 24, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
         using (var g = System.Drawing.Graphics.FromImage(a.Image))
         {
             g.DrawImage(b, new System.Drawing.Rectangle(0, 0, b.Width, b.Height));
         }
         if (b.PixelFormat != System.Drawing.Imaging.PixelFormat.Format32bppArgb)
             ((System.Drawing.Bitmap)a.Image).MakeTransparent(b.GetPixel(0, b.Height - 1));
         ms.Close();
         b.Dispose();
         a.Hidden = br.ReadInt32() == 0 ? false : true;
         a.Advanced = br.ReadInt32() == 0 ? false : true;
         a.RegisteredOnly = ver == 500 || (br.ReadInt32() == 0) ? false : true;
         a.Description = new string(br.ReadChars(br.ReadInt32()));
         a.ListText = new string(br.ReadChars(br.ReadInt32()));
         a.HintText = new string(br.ReadChars(br.ReadInt32()));
         a.Kind = (ActionKind)br.ReadInt32();
         a.InterfaceKind = (ActionInferfaceKind)br.ReadInt32();
         a.IsQuestion = br.ReadInt32() == 0 ? false : true;
         a.ShowApplyTo = br.ReadInt32() == 0 ? false : true;
         a.ShowRelative = br.ReadInt32() == 0 ? false : true;
         a.ArgumentCount = br.ReadInt32();
         int count = br.ReadInt32();
         if (a.Arguments.Length != count)
             a.Arguments = new ActionArgument[count];
         for (int j = 0; j < count; j++)
         {
             a.Arguments[j] = new ActionArgument();
             a.Arguments[j].Caption = new string(br.ReadChars(br.ReadInt32()));
             a.Arguments[j].Type = (ActionArgumentType)br.ReadInt32();
             a.Arguments[j].DefaultValue = new string(br.ReadChars(br.ReadInt32()));
             a.Arguments[j].Menu = new string(br.ReadChars(br.ReadInt32()));
         }
         a.ExecutionType = (ActionExecutionType)br.ReadInt32();
         a.FunctionName = new string(br.ReadChars(br.ReadInt32()));
         a.Code = new string(br.ReadChars(br.ReadInt32()));
         lib.Actions.Add(a);
     }
     //Hmm...
     //ActionDefinition d = new ActionDefinition(lib);
     //d.Description = "Font...";
     //d.ArgumentCount = 1;
     //d.Arguments[0] = new ActionArgument();
     //d.Arguments[0].Type = ActionArgumentType.FontString;
     //d.ListText = "@0";
     //lib.Actions.Add(d);
     //d.Arguments[0].DefaultValue = "\"Times New Roman\",10,0,0,0,0,0";
     return lib;
 }
开发者ID:MilesBoulanger,项目名称:game-creator,代码行数:73,代码来源:ActionLibrary.cs

示例12: vdxChooser_SelectedIndexChanged

        private void vdxChooser_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (game == GameID.T7G)
            {
                if (vdx != null)
                    vdx.stop();

                string file = vdxChooser.SelectedItem.ToString();

                GJD.RLData rl;
                System.IO.BinaryReader reader = gjd.getVDX(file, out rl);
                if (reader != null)
                {
                    if (midi != null)
                        midi.Close();
                    if (!gjd.Name.Contains("xmi"))
                        vdx = new VDX(reader, rl, s);
                    else
                    {
                        if (!System.IO.File.Exists(path + "mid\\" + file.Substring(0, file.IndexOf(".")) + ".mid"))
                        {
                            System.Diagnostics.Process p = new System.Diagnostics.Process();
                            p.StartInfo.FileName = path + "mid\\xmi2mid.exe";
                            p.StartInfo.Arguments = path + "mid\\" + file.Substring(0, file.IndexOf(".") + 4) + " " + path + "mid\\" + file.Substring(0, file.IndexOf(".")) + ".mid";
                            p.StartInfo.UseShellExecute = false;
                            p.StartInfo.WorkingDirectory = path + "mid\\";
                            System.Threading.Thread.Sleep(500);
                            p.Start();
                            p.WaitForExit();
                            System.Console.WriteLine("Missing midi");
                        }
                        if (System.IO.File.Exists(path + "mid\\" + file.Substring(0, file.IndexOf(".")) + ".mid"))
                        {
                            midi = new SdlDotNet.Audio.Music(path + "mid\\" + file.Substring(0, file.IndexOf(".")) + ".mid");
                            midi.Play(1);
                        }

                    }

                    modEnviron();

                    textBox1.Text = ((Array.IndexOf(gjd.filemap, gjd.Name) << 10) + rl.number).ToString();
                }
            }
            else
            {
                frameSeek.Enabled = false;
                // 11H
                if (gjdChooser.SelectedItem.ToString() == "Icons")
                {
                    Cursors_v2 cur = ((Cursors_v2)(this.gjdChooser.Tag));
                    frameSeek.Maximum = cur.cursors[vdxChooser.SelectedIndex == 4 ? 3 : vdxChooser.SelectedIndex].frames - 1;
                    frameSeek.Value = 0;
                    Cursors_v2.decodeCursor((byte)vdxChooser.SelectedIndex, 0, ref cur, ref s);
                    frameSeek.Enabled = true;
                }
                else
                {
                    // ROQ parser
                    if (roq != null)
                        roq.stop();
                    roq = null;

                    GJD.RLData rl = new GJD.RLData();

                    foreach (GJD.RLData subrl in V2_RL[gjdChooser.SelectedIndex])
                    {
                        if (subrl.filename == vdxChooser.SelectedItem.ToString())
                        {
                            rl = subrl;
                            break;
                        }
                    }
                    System.IO.BinaryReader r = new System.IO.BinaryReader(new System.IO.FileStream(path + "\\media\\" + gjdChooser.SelectedItem, System.IO.FileMode.Open,  System.IO.FileAccess.Read, System.IO.FileShare.Read));
                    r.BaseStream.Seek(rl.offset, System.IO.SeekOrigin.Begin);

                    System.IO.BinaryReader reader = new System.IO.BinaryReader(new System.IO.MemoryStream(r.ReadBytes((int)rl.length)));
                    if (rl.filename.Contains("xmi"))
                    {
                        roq = null;
                        string file = rl.filename;
                        if (file.Contains("\0"))
                            file = file.Substring(0, file.IndexOf("\0"));

                        if (!System.IO.File.Exists(path + "mid\\" + file))
                        {
                            byte[] buffer = new byte[reader.BaseStream.Length];
                            reader.Read(buffer, 0, buffer.Length);
                            System.IO.File.WriteAllBytes(path + "mid\\" + file, buffer);
                        }

                        if (!System.IO.File.Exists(path + "mid\\" + file.Substring(0, file.IndexOf(".")) + ".mid"))
                        {
                            System.Diagnostics.Process p = new System.Diagnostics.Process();
                            p.StartInfo.FileName = path + "mid\\xmi2mid.exe";
                            p.StartInfo.Arguments = path + "mid\\" + file.Substring(0, file.IndexOf(".") + 4) + " " + path + "mid\\" + file.Substring(0, file.IndexOf(".")) + ".mid";
                            p.StartInfo.UseShellExecute = false;
                            p.StartInfo.WorkingDirectory = path + "mid\\";
                           // System.Threading.Thread.Sleep(500);
                           // p.Start();
//.........这里部分代码省略.........
开发者ID:scott-t,项目名称:GJDBrowser,代码行数:101,代码来源:frmMain.cs

示例13: Deserialize

 public static RangedListFilter Deserialize(byte[] bytes)
 {
     using (System.IO.MemoryStream MS = new System.IO.MemoryStream (bytes, false)) {
         using (System.IO.BinaryReader BR = new System.IO.BinaryReader (MS)) {
             int itemCount = BR.ReadInt32 ();
             int skipBytes = BR.ReadInt32 ();
             byte[] skippedBytes = BR.ReadBytes (skipBytes);
             byte[][] items = new byte[itemCount][];
             for (int n = 0; n != itemCount; n++) {
                 int itemLength = BR.ReadInt32 ();
                 byte[] item = new byte[skipBytes + itemLength];
                 System.Buffer.BlockCopy (skippedBytes, 0, item, 0, skipBytes);
                 BR.Read (item, skipBytes, itemLength);
                 items [n] = item;
             }
             return new RangedListFilter (new [] { items });
         }
     }
 }
开发者ID:vebin,项目名称:BD2,代码行数:19,代码来源:RangedListFilter.cs

示例14: readBinaryFile

        /// <summary>
        /// CML: Created shared binary reader to ensure the file is being read correctly.
        /// </summary>
        /// <param name="File"></param>
        /// <returns>An array containing data.  Array is sized for the data from the file.</returns>
        public static byte[] readBinaryFile(System.IO.FileInfo File)
        {
            byte[] data = new byte[(int)File.Length];
            System.IO.BinaryReader fis = null;
            try
                {
                fis = new System.IO.BinaryReader(new System.IO.FileStream(File.FullName, System.IO.FileMode.Open, System.IO.FileAccess.Read));
                fis.Read(data, 0, data.Length);
                }
            finally
                {
                if (fis != null)
                    fis.Close();
                }

            return data;
        }
开发者ID:advdig,项目名称:advgp2_administracion,代码行数:22,代码来源:Drawing.cs

示例15: LoadPhoto

        private void LoadPhoto(Profile profile, string path, string type)
        {
            if (!System.IO.File.Exists(path))
            {
                return;
            }

            System.IO.FileStream fs = null;
            System.IO.BinaryReader br = null;

            try
            {
                fs = new System.IO.FileStream(path, System.IO.FileMode.Open, System.IO.FileAccess.Read);
                br = new System.IO.BinaryReader(fs);

                long fileSize = fs.Length;
                byte[] buffer = new byte[fileSize];
                br.Read(buffer, 0, (int)buffer.Length);

                br.Close();
                fs.Close();

                profile.Photo = buffer;
                profile.PhotoFilename = path;
                profile.PhotoMimeType = type;
                profile.PhotoSize = buffer.Length;
                profile.PhotoUploadedOn = DateTime.Now;
            }
            catch
            { }
            finally
            {
                if (br != null) br.Close();
                if (fs != null) fs.Close();
            }
        }
开发者ID:johnsevillano,项目名称:babylon,代码行数:36,代码来源:MockProfilesProvider.cs


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