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


C# BinaryWriter.Close方法代码示例

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


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

示例1: JoinFile

    public static void JoinFile(string inputFile, string outputFile, KsSplitJoinHandler handler)
    {
        long rwIncrament=500000;//updateInterval=400000, updateIndex=0;
        FileInfo fInfo=new FileInfo(inputFile);
        long iLen=fInfo.Length;
        FileStream ifs=new FileStream(inputFile, FileMode.Open);
        BinaryReader reader=new BinaryReader(ifs);
        //bool cont;

        FileInfo fi=new FileInfo(outputFile);
        FileMode fm=FileMode.Append;
        if(!fi.Exists) fm=FileMode.CreateNew;
        FileStream ofs=new FileStream(outputFile, fm);
        BinaryWriter writer=new BinaryWriter(ofs);

        long i=0, cnt;
        while(i<iLen) {
            cnt=rwIncrament;
            if((i+cnt)>=iLen) cnt=iLen-i;
            //byte val[cnt];
            writer.Write(reader.ReadBytes((int)cnt));
            i+=cnt;
            if(!handler.OnUpdate(inputFile, outputFile, i, iLen)) {
                ifs.Close(); reader.Close();
                ofs.Close(); writer.Close();
                handler.OnCanceled(inputFile, outputFile, i, iLen);
                return;
            }
        }

        ifs.Close(); reader.Close();
        ofs.Close(); writer.Close();
        handler.OnFinished(inputFile, outputFile, i, iLen);
    }
开发者ID:erin100280,项目名称:KnifeSpan,代码行数:34,代码来源:KsJoiner.cs

示例2: SaveItems

	public void SaveItems()
	{
		MemoryStream ms = null;
		BinaryWriter writer = null;
//		CryptoStream encStream = null;
//		FileStream file = null;
		
		try 
		{
			ms = new MemoryStream();
			
//			DESCryptoServiceProvider mDES = new DESCryptoServiceProvider();
//			mDES.Mode = CipherMode.ECB;
//			mDES.Key = System.Text.Encoding.UTF8.GetBytes(TweaksSystem.CRYPTO_KEY);
//			
//			CryptoStream encStream = new CryptoStream(ms, mDES.CreateEncryptor(), CryptoStreamMode.Write);
			
//			BinaryWriter writer = new BinaryWriter(encStream);
			writer = new BinaryWriter(ms);
			
			if (writer != null) {
				writer.Write(UserCloud.USER_DATA_VERSION);
				writer.Write(icePicks);
				writer.Write(snowballs);
				writer.Write(hourglasses);
				writer.Write(itemTokens);
				
				writer.Close();
			}
			
//			encStream.Close();
			
			ms.Close();
			File.WriteAllBytes(saveFile, ms.ToArray());
		}
		catch (Exception ex)
		{
			Debug.Log("Error in create or save user file data. Exception: " + ex.Message);
		}
		finally 
		{
			if (writer != null) {
				writer.Close();
			}
			if (ms != null) {
				ms.Close();
			}
		}
	}
开发者ID:JulyMars,项目名称:frozen_free_fall,代码行数:49,代码来源:TokensSystem.cs

示例3: GetMemberOrParent

    public void GetMemberOrParent(string id)
    {
        IList<Hashtable> listMembers = bl.GetmemberInfo(id, 0);
        IList<Hashtable> list = null;
        string imgs = "";
        if (listMembers != null)
        {
            list = bl.GetmemberInfo(id, 1);
            Hashtable htb = new Hashtable();
            htb = listMembers[0];

            if (htb["B_ATTACHMENT"] != null && htb["B_ATTACHMENT"].ToString() != "")
            {
                byte[] imgBytes = (byte[])(htb["B_ATTACHMENT"]);

                string filePath = "../Files/" + htb["T_USERID"] + ".jpg";
                imgs = filePath;
                filePath = Server.MapPath(filePath);
                BinaryWriter bw = new BinaryWriter(File.Open(filePath, FileMode.OpenOrCreate));
                bw.Write(imgBytes);
                bw.Close();
            }

        }
        obj = new
        {
            img = imgs,
            list = list,
        };
        string result = JsonConvert.SerializeObject(obj);
        Response.Write(result);
        Response.End();
    }
开发者ID:eseawind,项目名称:YCJN,代码行数:33,代码来源:ManageOrgUser.aspx.cs

示例4: FileStream

    IEnumerator ShareScreenshotInterface.ShareScreenshot(byte[] screenshot, bool isProcessing, string shareText, string gameLink, string subject)
    {
        isProcessing = true;

        string destination = Path.Combine(Application.persistentDataPath, "Screenshot.png");
        FileStream fs = new FileStream(destination, FileMode.OpenOrCreate);
        BinaryWriter ww = new BinaryWriter(fs);
        ww.Write(screenshot);
        ww.Close();
        fs.Close();

        AndroidJavaClass intentClass = new AndroidJavaClass("android.content.Intent");
        AndroidJavaObject intentObject = new AndroidJavaObject("android.content.Intent");
        intentObject.Call<AndroidJavaObject>("setAction", intentClass.GetStatic<string>("ACTION_SEND"));
        AndroidJavaClass uriClass = new AndroidJavaClass("android.net.Uri");
        AndroidJavaObject uriObject = uriClass.CallStatic<AndroidJavaObject>("parse", "file://" + destination);
        intentObject.Call<AndroidJavaObject>("putExtra", intentClass.GetStatic<string>("EXTRA_STREAM"), uriObject);
        intentObject.Call<AndroidJavaObject>("putExtra", intentClass.GetStatic<string>("EXTRA_TEXT"), shareText + gameLink);
        intentObject.Call<AndroidJavaObject>("putExtra", intentClass.GetStatic<string>("EXTRA_SUBJECT"), subject);
        intentObject.Call<AndroidJavaObject>("setType", "image/png");
        AndroidJavaClass unity = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
        AndroidJavaObject currentActivity = unity.GetStatic<AndroidJavaObject>("currentActivity");

        currentActivity.Call("startActivity", intentObject);

        isProcessing = false;

        yield return new WaitForSeconds(1);
    }
开发者ID:wishexxt,项目名称:UnityTestProject,代码行数:29,代码来源:ShareScreenshotAndroid.cs

示例5: makeAtlas

    public static void makeAtlas(Texture2D[] textures)
    {
        if (textures != null && textures.Length > 1)
        {
            // Make our atlas gameobject with a blank atlas script on it.
            GameObject go = new GameObject("TEST_ATLAS");
            go.AddComponent<Atlas>();

            // The blank texture is replaced with the packed texture.
            Texture2D tex = new Texture2D(2, 2);

            // Now pack the textures
            Rect[] UVs = tex.PackTextures(textures, 2, 4096);

            // Create out spriteAnimation components onto the atlas with height/width equal to the source.
            for (int i = 0; i < UVs.Length; i++)
            {
                SpriteAnimation anim = go.AddComponent<SpriteAnimation>();
                anim.setData(textures[i].name, UVs[i]);
            }

            FileStream fs = new FileStream(Application.dataPath + "/Resources/Sprites/Atlas_Sprite.png", FileMode.Create);
            BinaryWriter bw = new BinaryWriter(fs);
            bw.Write(tex.EncodeToPNG());
            bw.Close();
            fs.Close();

            //PrefabUtility.CreatePrefab(Application.dataPath + "/Resources/Atlases/" + go.name + ".prefab", go);
        }
        else
        {
            Debug.LogWarning("Given Textures are null or singular.");
        }
    }
开发者ID:joeywodarski,项目名称:Electric,代码行数:34,代码来源:Utils.cs

示例6: RpcTellClientTime

    public void RpcTellClientTime(int current_count)
    {
        current_count = 60 * 5 - current_count;

        int min = current_count / 60;
        int sec = current_count % 60;

        int ten_sec = sec / 10;
        int one_sec = sec % 10;

        score_.text = "ClearTime:" + min.ToString() + ":" + ten_sec.ToString() + one_sec.ToString();
        score_.gameObject.SetActive(true);
        hi_score_text_.gameObject.SetActive(true);

        if (current_count > hi_score_) return;
        if (is_director_) return;
        is_director_ = true;

        {
            var path = Application.dataPath + "/" + "ranki.txt";
            FileStream fs = new FileStream(path, FileMode.Create, FileAccess.Write);
            BinaryWriter writer = new BinaryWriter(fs);

            if (writer != null)
            {
                writer.Write(current_count);
                writer.Close();
            }
        }

        StartCoroutine(ChangeColor());
    }
开发者ID:ooHIROoo,项目名称:BattleArms,代码行数:32,代码来源:EndDirector.cs

示例7: CreatePhoto

    void CreatePhoto()
    {
        try
        {
            string strPhoto = Request.Form["imageData"]; //Get the image from flash file
            byte[] photo = Convert.FromBase64String(strPhoto);

            string dirUrl = "~/Uploads/cuc_Picture/";
            string dirPath = Server.MapPath(dirUrl);

            if (!Directory.Exists(dirPath))
            {
                Directory.CreateDirectory(dirPath);
            }

            FileStream fs = new FileStream(dirPath+"St_Pic.jpg", FileMode.OpenOrCreate, FileAccess.Write);
            BinaryWriter br = new BinaryWriter(fs);
            br.Write(photo);
            br.Flush();
            br.Close();
            fs.Close();

            string camimg = dirPath + "St_Pic.jpg";

            Session["imagePath"] = camimg;

        }
        catch (Exception Ex)
        {

        }
    }
开发者ID:anam,项目名称:mal,代码行数:32,代码来源:ImageConversions.aspx.cs

示例8: Start

    // Use this for initialization
    void Start()
    {
        var path = Application.dataPath + "/" + "ranki.txt";

        if (!File.Exists(path))
        {
            {
                FileStream fs = new FileStream(path, FileMode.Create, FileAccess.Write);
                BinaryWriter writer = new BinaryWriter(fs);

                if (writer != null)
                {
                    writer.Write(100000);
                    writer.Close();
                }
            }
        }

        {
            FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read);
            BinaryReader reader = new BinaryReader(fs);

            if (reader != null)
            {
                var i = reader.ReadInt32();
                reader.Close();
                Debug.Log(i);
            }
        }
    }
开发者ID:ooHIROoo,项目名称:BattleArms,代码行数:31,代码来源:JumpTest.cs

示例9: Write

	public void Write (float[] clipData, WaveFormatChunk format, FileStream stream)
	{
		WaveHeader header = new WaveHeader ();
		WaveDataChunk data = new WaveDataChunk ();
		
		data.shortArray = new short[clipData.Length];
		for (int i = 0; i < clipData.Length; i++)
			data.shortArray [i] = (short)(clipData [i] * 32767);
		
		data.dwChunkSize = (uint)(data.shortArray.Length * (format.wBitsPerSample / 8));
		
		BinaryWriter writer = new BinaryWriter (stream);
		writer.Write (header.sGroupID.ToCharArray ());
		writer.Write (header.dwFileLength);
		writer.Write (header.sRiffType.ToCharArray ());
		writer.Write (format.sChunkID.ToCharArray ());
		writer.Write (format.dwChunkSize);
		writer.Write (format.wFormatTag);
		writer.Write (format.wChannels);
		writer.Write (format.dwSamplesPerSec);
		writer.Write (format.dwAvgBytesPerSec);
		writer.Write (format.wBlockAlign);
		writer.Write (format.wBitsPerSample);
		writer.Write (data.sChunkID.ToCharArray ());
		writer.Write (data.dwChunkSize);
		foreach (short dataPoint in data.shortArray) {
			writer.Write (dataPoint);
		}
		writer.Seek (4, SeekOrigin.Begin);
		uint filesize = (uint)writer.BaseStream.Length;
		writer.Write (filesize - 8);
		writer.Close ();
	}
开发者ID:SnotE101,项目名称:ATT_APIPlatform_Unity_SDK,代码行数:33,代码来源:WaveGen.cs

示例10: ExtractFile

	public static void ExtractFile(ListViewFileItem lvi, string exeName, string outName)
	{
		//extract file in ListViewFileItem
		FileStream fsIn = null;
		BinaryReader brIn = null;
		FileStream fsOut = null;
		BinaryWriter bwOut = null;
		try
		{
			fsIn = new FileStream(exeName, FileMode.Open);
			brIn = new BinaryReader(fsIn);
			fsOut = new FileStream(outName, FileMode.Create);
			bwOut = new BinaryWriter(fsOut);
			fsIn.Seek(lvi.Offset, SeekOrigin.Begin);
			bwOut.Write(brIn.ReadBytes(lvi.Size));
		}
		catch (Exception ex)
		{
			MessageBox.Show(ex.ToString(), "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
		}
		finally
		{
			if (brIn != null)
				brIn.Close();
			if (fsIn != null)
				fsIn.Close();
			if (bwOut != null)
				bwOut.Close();
			if (fsOut != null)
				fsOut.Close();
		}
	}
开发者ID:winch,项目名称:winch.pinkbile.com-c-sharp,代码行数:32,代码来源:proExe.cs

示例11: ReadBlob

	// read the BLOB into file "cs-parser2.cs"
	public static void ReadBlob (OracleConnection connection) 
	{
		if (File.Exists(outfilename) == true) {
			Console.WriteLine("Filename already exists: " + outfilename);
			return;
		}

		OracleCommand rcmd = connection.CreateCommand ();
		rcmd.CommandText = "SELECT BLOB_COLUMN FROM BLOBTEST";
		OracleDataReader reader2 = rcmd.ExecuteReader ();
		if (!reader2.Read ())
			Console.WriteLine ("ERROR: RECORD NOT FOUND");

		Console.WriteLine ("  TESTING OracleLob OBJECT 2...");
		OracleLob lob2 = reader2.GetOracleLob (0);
		Console.WriteLine ("  LENGTH: {0}", lob2.Length);
		Console.WriteLine ("  CHUNK SIZE: {0}", lob2.ChunkSize);

		byte[] lobvalue = (byte[]) lob2.Value;
		
		if (ByteArrayCompare(bytes1, lobvalue) == true)
			Console.WriteLine("bytes1 and bytes2 are equal: good");
		else 
			Console.WriteLine("bytes1 and bytes2 are not equal: bad");

		FileStream fs = new FileStream(outfilename, FileMode.CreateNew);
		BinaryWriter w = new BinaryWriter(fs);
		w.Write(lobvalue);
		w.Close();
		fs.Close();

		lob2.Close ();
		reader2.Close ();
	}
开发者ID:nlhepler,项目名称:mono,代码行数:35,代码来源:testblob.cs

示例12: ExecuteSaveFontTexture

    public static void ExecuteSaveFontTexture()
    {
        Texture2D tex = Selection.activeObject as Texture2D;
        if (tex == null)
        {
            EditorUtility.DisplayDialog("No texture selected", "Please select a texture", "Cancel");
            return;
        }

        if (tex.format != TextureFormat.Alpha8)
        {
            EditorUtility.DisplayDialog("Wrong format", "Texture must be in uncompressed Alpha8 format", "Cancel");
            return;
        }

        // Convert Alpha8 texture to ARGB32 texture so it can be saved as a PNG
        var texPixels = tex.GetPixels();
        var tex2 = new Texture2D(tex.width, tex.height, TextureFormat.ARGB32, false);
        tex2.SetPixels(texPixels);

        // Save texture (WriteAllBytes is not used here in order to keep compatibility with Unity iPhone)
        var texBytes = tex2.EncodeToPNG();
        var fileName = EditorUtility.SaveFilePanel("Save font texture", "", "font Texture", "png");
        if (fileName.Length > 0)
        {
            FileStream f = new FileStream(fileName, FileMode.OpenOrCreate, FileAccess.Write);
            BinaryWriter b = new BinaryWriter(f);
            for (var i = 0; i < texBytes.Length; i++) b.Write(texBytes[i]);
            b.Close();
        }

        GameObject.DestroyImmediate(tex2);
    }
开发者ID:azanium,项目名称:Klumbi-Unity,代码行数:33,代码来源:SaveFontTexture.cs

示例13: GetResourcesFrameRender

    public static void GetResourcesFrameRender(Dictionary<string, string> taskdetails)
    {
        FileStream fs;
        BinaryWriter bw;

        Dictionary<string, string> response = XMLRPC.Instance.getFrameRenderResources(Convert.ToInt32(taskdetails["projid"]));

        string resourcefilepath = "resources" + Config.Instance.Slash() + response["filename"];

        //Open File for writing
        fs = new FileStream(resourcefilepath, FileMode.OpenOrCreate, FileAccess.Write);
        bw = new BinaryWriter(fs);

        bw.Write(Convert.FromBase64String(response["data"]));
        bw.Flush();
        bw.Close();
        fs.Close();

        //Is the file a archive.. then unpack it
        if (Path.GetExtension(response["filename"]) == ".zip")
        {
            Archive oArchive = new Archive(resourcefilepath);
            oArchive.Extract("resources");
        }
    }
开发者ID:defcon8,项目名称:GNURender,代码行数:25,代码来源:Main.cs

示例14: Start

    public void Start()
    {
        this.allotedReadingTime = 9;
        FileStream fs;

        if (!File.Exists("scenes.bin"))
        {

            fs = new FileStream("scenes.bin", FileMode.Create);
            BinaryWriter bw = new BinaryWriter(fs);
            bw.Write("In November 11, 2015, a barangay hall as well as three houses were gutted by a fire which was reportedly caused by an electrical short circuit\r\nfire\r\nFour families were left homesless after an unattended open flame may have caused the fire that started at 5:37 A.M.\r\nfire\r\nSeven rooms of a three-story old boarding house were damaged in an early morning fire. Electrical misuse is being looked into as a possible cause of the fire.\r\nfire\r\nThree houses were damaged in a fire which was caused by an unattended candle.\r\nfire\r\nAn eight-year-old girl died in a fire. Fire investigators said the fire may have been caused by a lighted candle that fell onto a bed.\r\fire\r\nA morning fire razed a two-storey house and a two-door apartment and damanged another house. The fire was cause by two children who were playing with matches at the second floor.\r\nfire\r\n");
            bw.Close();
            fs.Close();

        }

        fs = new FileStream("scenes.bin", FileMode.Open);
        StreamReader str = new StreamReader (fs);

        while (!str.EndOfStream){
            preventiveLine.Add(new Preventive{message = str.ReadLine(), element = str.ReadLine()});
        }
        Debug.Log(preventiveLine.Count + "Size");
        //Debug.Log(preventiveLine.Count+" all");
        if (this.size == 0){
            this.randomNumber = Random.Range(0, preventiveLine.Count);
            scene[this.size] = this.randomNumber;
            this.size++;
            Debug.Log("size is zero and now "+ this.size);
        }
        else{
            this.proceed = false;
            do
            {
                this.randomNumber = Random.Range(0, preventiveLine.Count);
                for (int x = 0; x <= this.size ; x++)
                {
                    if (scene[x] == this.randomNumber){
                        Debug.Log("same number index "+ x);
                        this.proceed = true;
                    }
                }
                if (this.proceed)
                {
                    Debug.Log("Cant proceed");
                    this.proceed = false;
                }
                else {
                    Debug.Log("display");
                    this.proceed = true;
                    scene[this.size] = this.randomNumber;
                    this.size++;
                }

            } while (proceed != true);
        }

        Debug.Log(this.size+ " array size");
    }
开发者ID:jMelgar101,项目名称:ITProject,代码行数:59,代码来源:Readers.cs

示例15: Start

    // Use this for initialization
    void Start()
    {
        FileStream fs = new FileStream ("test.dem",FileMode.Create, FileAccess.Write);
        BinaryWriter bw = new BinaryWriter (fs);
        StreamReader sr = new StreamReader ("36814.xyz");
        ArrayList height = new ArrayList ();

        int[] regionMin = new int[2];
        int[] regionMax = new int[2];

        string[] words = (sr.ReadLine()).Split (' ');
        float interval = 90;
        Int32 X = (int)Convert.ToDouble (words [0]);
        Int32 Y = (int)Convert.ToDouble (words [1]);
        height.Add (words [2]);

        regionMax [0] = regionMin [0] = X;
        regionMax [1] = regionMin [1] = Y;

        while (sr.Peek() >= 0) {
            words = (sr.ReadLine()).Split (' ');
            X = (int)Convert.ToDouble (words [0]);
            Y = (int)Convert.ToDouble (words [1]);
            height.Add (words [2]);

            if(regionMax[0]<X)
                regionMax[0] = X;
            if(regionMin[0]>X)
                regionMin[0] = X;

            if(regionMax[1] <Y)
                regionMax[1] = Y;
            if(regionMin[1] > Y)
                regionMin[1] = Y;

        }

        bw.Write (interval);
        bw.Write (regionMin [0]);
        bw.Write (regionMin [1]);
        bw.Write (regionMax [0]);
        bw.Write (regionMax[1]);

        for (int i=0; i<height.Count; i++) {
            bw.Write(Convert.ToDouble(height[i]));
        }

        //bw.Write (Convert.ToDouble(words[0]));
        //bw.Write (Convert.ToDouble(words[1]));

        /*FileStream fs2 = new FileStream ("test.dem", FileMode.Open, FileAccess.Read);
            BinaryReader br = new BinaryReader (fs2);
            Console.WriteLine (br.ReadDouble());
            Console.WriteLine (br.ReadDouble());*/

        sr.Close ();
        bw.Close ();
        fs.Close ();
    }
开发者ID:Hyunsik-Yoo,项目名称:Flood-Simulation,代码行数:60,代码来源:DEMTransfer.cs


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