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


C# FileStream.WriteByte方法代码示例

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


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

示例1: Main

 static void Main( )
 {
     Stream s = new FileStream ( "foo.txt" , FileMode.Create ) ;
     s.WriteByte ( 67 ) ;
     s.WriteByte ( 35 ) ;
     s.Close ( ) ;
 }
开发者ID:JeremiahZhang,项目名称:AKA,代码行数:7,代码来源:TextFile.cs

示例2: BasicFlushFunctionality

        public void BasicFlushFunctionality(bool? flushToDisk)
        {
            using (FileStream fs = new FileStream(GetTestFilePath(), FileMode.Create))
            {
                fs.WriteByte(0);
                Flush(fs, flushToDisk);

                fs.WriteByte(0xFF);
                Flush(fs, flushToDisk);
            }
        }
开发者ID:dotnet,项目名称:corefx,代码行数:11,代码来源:Flush.cs

示例3: BasicFlushAsyncFunctionality

        public async Task BasicFlushAsyncFunctionality()
        {
            using (FileStream fs = new FileStream(GetTestFilePath(), FileMode.Create))
            {
                fs.WriteByte(0);
                await fs.FlushAsync();

                fs.WriteByte(0xFF);
                await fs.FlushAsync();
            }
        }
开发者ID:ChuangYang,项目名称:corefx,代码行数:11,代码来源:FlushAsync.cs

示例4: Main

    public static void Main(string[] args)
    {
        if (args.Length < 3 || !File.Exists(args[0]))
        {
            Console.WriteLine("pad file_in file_out pad");
            return;
        }

        byte[] file_in = File.ReadAllBytes(args[0]);
        FileStream file_out = new FileStream(args[1], FileMode.Create);
        byte[] pad = new byte[args[2].Length*sizeof(char)];
        System.Buffer.BlockCopy(args[2].ToCharArray(), 0, pad, 0, pad.Length);

        // cheap hack deals with c# unicode default
        for (int i = 0; i < pad.Length; i++) if (i%2==0) pad[i+1] = pad[i];

        byte b_read = 0;
        int p = 0;
        for (long i = 0; i < file_in.Length; i++)
        {
            b_read = (byte) (file_in[i] ^ pad[p++]);
            if (p >= pad.Length) p = 0;
            file_out.WriteByte(b_read);
        }
        file_out.Close();
    }
开发者ID:davidhartnett,项目名称:pad,代码行数:26,代码来源:pad.cs

示例5: ReadOnlyThrows

        public void ReadOnlyThrows()
        {
            string fileName = GetTestFilePath();
            using (FileStream fs = new FileStream(fileName, FileMode.Create))
            {
                fs.Write(TestBuffer, 0, TestBuffer.Length);
            }

            using (FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read))
            {
                Assert.Throws<NotSupportedException>(() => fs.WriteByte(0));

                fs.Dispose();
                // Disposed checking happens first
                Assert.Throws<ObjectDisposedException>(() => fs.WriteByte(0));
            }
        }
开发者ID:ESgarbi,项目名称:corefx,代码行数:17,代码来源:WriteByte.cs

示例6: ReadDisposedThrows

 public void ReadDisposedThrows()
 {
     using (FileStream fs = new FileStream(GetTestFilePath(), FileMode.Create))
     {
         fs.Dispose();
         Assert.Throws<ObjectDisposedException>(() => fs.WriteByte(0));
     }
 }
开发者ID:ESgarbi,项目名称:corefx,代码行数:8,代码来源:WriteByte.cs

示例7: StartWriting

	void StartWriting (string name)
	{
		fileStream = new FileStream(name, FileMode.Create); 
		byte emptybyte = new byte();

		for(int i = 0; i<headerSize; i++) //preparing the header
		{
			fileStream.WriteByte(emptybyte);
		}
	}
开发者ID:englandjf,项目名称:musicProject,代码行数:10,代码来源:soundRecord.cs

示例8: CreateEmpty

	static FileStream CreateEmpty(string filepath) {
		var fileStream = new FileStream(filepath, FileMode.Create);
	    byte emptyByte = new byte();
 
	    for(int i = 0; i < HEADER_SIZE; i++) //preparing the header
	    {
	        fileStream.WriteByte(emptyByte);
	    }
 
		return fileStream;
	}
开发者ID:MedStarSiTEL,项目名称:UnityTrauma,代码行数:11,代码来源:SaveWav.cs

示例9: FlushAsyncWhenNothingToFlush

        public async Task FlushAsyncWhenNothingToFlush()
        {
            using (FileStream fs = new FileStream(GetTestFilePath(), FileMode.Create))
            {
                fs.WriteByte(0);
                await fs.FlushAsync();

                await fs.FlushAsync();
                await fs.FlushAsync();
                await fs.FlushAsync();
            }
        }
开发者ID:ChuangYang,项目名称:corefx,代码行数:12,代码来源:FlushAsync.cs

示例10: FlushWhenNothingToFlush

        public void FlushWhenNothingToFlush(bool? flushToDisk)
        {
            using (FileStream fs = new FileStream(GetTestFilePath(), FileMode.Create))
            {
                fs.WriteByte(0);
                Flush(fs, flushToDisk);

                Flush(fs, flushToDisk);
                Flush(fs, flushToDisk);
                Flush(fs, flushToDisk);
            }
        }
开发者ID:dotnet,项目名称:corefx,代码行数:12,代码来源:Flush.cs

示例11: Main

 public static void Main(string[] args)
 {
     byte [] bytes = {70,71,72,73,74,75,13,10};
     FileStream strm = new FileStream(@"..\..\WriteBinary.txt", FileMode.OpenOrCreate, FileAccess.Write);
     foreach (byte bNext in bytes)
     {
         Console.WriteLine(bNext);
         strm.WriteByte(bNext);
     }
     strm.Close();
     Console.WriteLine("All done.");
     Console.ReadLine();
 }
开发者ID:Nagato23,项目名称:CsBasic,代码行数:13,代码来源:WriteBinary.cs

示例12: Main

 static void Main()
 {
     using (var file = new FileStream("../../../view.jpg", FileMode.Open))
     {
         using (var copyFile = new FileStream("../../CopyView.jpg", FileMode.Create))
         {
             while (file.Position < file.Length)
             {
                 copyFile.WriteByte((byte)file.ReadByte());
             }
         }
     }
 }
开发者ID:teodory,项目名称:SoftUni-Homeworks,代码行数:13,代码来源:Problem4.cs

示例13: Main

	static int Main (string [] args)
	{
		using (FileStream fs = new FileStream ("tmp.txt", FileMode.Create, FileAccess.Write, FileShare.Read)) {
			fs.WriteByte (5);
			fs.Close ();
		}

		FileStream fs2 = new FileStream ("tmp.txt", FileMode.Open, FileAccess.Read, FileShare.Read);
		try {
			File.Delete ("tmp.txt");
			return 1;
		} catch (IOException) {
			fs2.Close ();
			File.Delete ("tmp.txt");
			return 0;
		}
	}
开发者ID:mono,项目名称:gert,代码行数:17,代码来源:test.cs

示例14: WriteFile

        public void WriteFile()
        {
            string fileName = GetTestFilePath();
            using (FileStream fs = new FileStream(fileName, FileMode.Create))
            {
                foreach(byte b in TestBuffer)
                {
                    fs.WriteByte(b);
                }
            }

            using (FileStream fs = new FileStream(fileName, FileMode.Open))
            {
                byte[] buffer = new byte[TestBuffer.Length];
                Assert.Equal(TestBuffer.Length, fs.Read(buffer, 0, buffer.Length));
                Assert.Equal(TestBuffer, buffer);
            }
        }
开发者ID:ESgarbi,项目名称:corefx,代码行数:18,代码来源:WriteByte.cs

示例15: WriteFile_PastBufferSize

 public void WriteFile_PastBufferSize()
 {
     string fileName = GetTestFilePath();
     using (FileStream fs = new FileStream(fileName, FileMode.Create))
     {
         for (int written = 0; written < TestBuffer.Length * 1000; written++)
         {
             fs.WriteByte(TestBuffer[written % TestBuffer.Length]);
         }
     }
     byte[] buffer = File.ReadAllBytes(fileName);
     int offset = 0;
     while (offset < buffer.Length)
     {
         for (int i = 0; i < TestBuffer.Length; i++)
             Assert.Equal(TestBuffer[i], buffer[i + offset]);
         offset += TestBuffer.Length;
     }
 }
开发者ID:ESgarbi,项目名称:corefx,代码行数:19,代码来源:WriteByte.cs


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