博文
streamreader和streamwriter 例子(2007-09-18 10:39:00)
摘要:using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
namespace _5_4
{
class Program
{
private const string path = "E:\\test2.txt";
static void Main(string[] args)
{
StreamWriter sw = null;
try
{
sw = createfile();
writetext(sw);
readtext(sw);
......
filestream的一个例子(2007-09-16 23:40:00)
摘要:using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
namespace _5_2
{
class Program
{
static void Main(string[] args)
{
string path = @"E:\test.txt"; //文件路径 ,在c#中,只要在字符串前加@就可以不用转义字符,也可以写成:string path="E:\\test.txt".第一个\表示转义字符,
FileAccess access = FileAccess.Write; //确定filestream对象访问文件的方式,有3种方式,另外2种分别为:read(只读)readwrite(读写)
FileMode mode = FileMode.Create; //确定如何打开或创建文件,还有其他方式如:append(追加),open(打开)等,可以到msdn上找http://msdn2.microsoft.com/zh-cn/library/system.io.filemode(VS.80).aspx
&n......
MemoryStream 的一些例子(2007-09-16 21:34:00)
摘要:using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
namespace _5_1
{
class Program
{
static void Main(string[] args)
{
Stream s = null;
try
{
s = new MemoryStream();
writestream(s); ......
int byte【】数组转换(2007-09-16 16:46:00)
摘要:using System;
using System.Collections.Generic;
using System.Text;
namespace test
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine(sizeof(int));
Console.WriteLine(sizeof(ushort));
Console.WriteLine(sizeof(uint));
int u1 = 300;
byte[] buffer = BitConverter.GetBytes(u1); //int类型,转换为byte数组
for (int i = 0; i < buffer.Length; i++)
......