using System;
using System.IO;
class MyStream
{
private const string FILE_NAME = "Test.data";
public static void Main(String[] args)
{
// Create the new, empty data file.
if (File.Exists(FILE_NAME))
{
Console.WriteLine("{0} already exists!", FILE_NAME);
return;
}
FileStream fs = new FileStream(FILE_NAME, FileMode.CreateNew);
// Create the writer for data.
BinaryWriter w = new BinaryWriter(fs);
// Write data to Test.data.
for (int i = 0; i < 11; i++)
{
w.Write( (int) i);
}
w.Close();
fs.Close();
// Create the reader for data.
fs = new FileStream(FILE_NAME, FileMode.Open, FileAccess.Read);
BinaryReader r = new BinaryReader(fs);
// Read data from Test.data.
for (int i = 0; i < 11; i++)
{
Console.WriteLine(r.ReadInt32());
}
r.Close();
fs.Close();
}
}
----------------------------------------------------------------------
を参考にして
/// <summary>
/// ダウンロードバイナリ
/// </summary>
/// <param name="ServiceName"></param>
/// <param name="strFileName"></param>
public void Download_bin(String ServiceName, String strFileName)
{
// パラメータの作成
byte[] data = Encoding.ASCII.GetBytes("");
// リクエストの作成
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(strWebAppDomain + ServiceName);
req.Method = "POST";
req.ContentType = "application/x-www-form-urlencoded";
req.ContentLength = data.Length;
WebResponse res = req.GetResponse();
// レスポンスの読み取り
Stream resStream = res.GetResponseStream();
ArrayList al = new ArrayList();
int a = 0;
while (a != -1)
{
a = resStream.ReadByte();
al.Add(a);
}
resStream.Close();
// 書き込み
String FILE_NAME = strFileName;
File.Delete(FILE_NAME);
FileStream fs = new FileStream(FILE_NAME, FileMode.CreateNew);
// Create the writer for data.
BinaryWriter w = new BinaryWriter(fs);
// Write data to Test.data.
foreach(int i in al)
{
w.Write((byte)i);
}
w.Close();
fs.Close();
}
なんだけど、下のほうのソースは動かないソース、今日は眠いのでアイデアだけ示して寝る~
2007年8月21日火曜日
バイナリの取り扱い
2007年8月20日月曜日
2007年8月19日日曜日
Apple II用USB・Bluetooth増設ボード
http://madug.cocolog-nifty.com/weblog/2007/08/apple_iiusbblue_03aa.html
俺もFM-77L2にグラフィックカード2枚差し対応しないと(嘘)
2007年8月15日水曜日
物理クイズ(光の反射)
http://www.cotton-tree.com/garyu/archives/2007/04/post_233.html
http://www.cotton-tree.com/garyu/archives/2007/05/post_235.html
http://www.cotton-tree.com/garyu/archives/2007/05/post_236.html
http://satoshi.blogs.com/life/2007/08/post-7.html
http://satoshi.blogs.com/life/2007/08/post-9.html
こんなの10分で解けないよ、いい加減なこと言うのやめよう(泣
まず「膜」が出てこないよ、そこが自慢っぽいけど
私はグーグルで最後のリンク、回答編を「運良くひっかけた」けど、そんなもん勉強なんていわないし
そもそも、それなら「実験系の図」ってのが悪質な引っ掛けだしね.......慶応幼稚園を見習わないと
登録:
投稿 (Atom)