读取 .dat格式的文件(是关于证券方面的),16进制,第一次做到这个东西,不知道该如何下手,帮忙(急、重谢)用C#读取这种文件具体有两个案例(好像是dephi,不知道什么意思)地址是:
1、http://blog.5ilily.cn/article.asp?id=1687
2、http://www.pinggu.name/html/2008-3/19/298051.html 有人处理过这种事情,帮帮忙啊
1、http://blog.5ilily.cn/article.asp?id=1687
2、http://www.pinggu.name/html/2008-3/19/298051.html 有人处理过这种事情,帮帮忙啊
解决方案 »
- iframe中页面的传值问题
- SerialPort.Write()方法可以把数据写入标签吗?
- string 和 Hex之间的转换
- web页面DIV内容显示问题
- 有关Socket.Available的怪异问题,大家快来凑热闹,同时show一下各位的Socket珍藏代码
- 有个问题没有思路
- 请问一个关于类的问题,请大家帮忙解答一下,谢谢
- C#高手进。
- 通过c#创建windows用户,可下面的代码执行正确的,但是没有创建用户!请高手帮忙,解决了200相送,不够可以在加
- 未处理的“System.Data.OleDb.OleDbException”类型的异常
- 数据库插入的问题
- 请问C#使用字符串为数据索引如何实现?
整个拷贝一下MSDN:
using System;
using System.IO;
using System.Security.Permissions;class Test
{
static void Main()
{
// Load application settings.
AppSettings appSettings = new AppSettings();
Console.WriteLine("App settings.\nAspect Ratio: {0}, " +
"Lookup directory: {1},\nAuto save time: {2} minutes, " +
"Show status bar: {3}\n",
new Object[4]{appSettings.AspectRatio.ToString(),
appSettings.LookupDir, appSettings.AutoSaveTime.ToString(),
appSettings.ShowStatusBar.ToString()}); // Change the settings.
appSettings.AspectRatio = 1.250F;
appSettings.LookupDir = @"C:\Temp";
appSettings.AutoSaveTime = 10;
appSettings.ShowStatusBar = true; // Save the new settings.
appSettings.Close();
}
}// Store and retrieve application settings.
class AppSettings
{
const string fileName = "AppSettings#@@#.dat";
float aspectRatio;
string lookupDir;
int autoSaveTime;
bool showStatusBar; public float AspectRatio
{
get{ return aspectRatio; }
set{ aspectRatio = value; }
} public string LookupDir
{
get{ return lookupDir; }
set{ lookupDir = value; }
} public int AutoSaveTime
{
get{ return autoSaveTime; }
set{ autoSaveTime = value; }
} public bool ShowStatusBar
{
get{ return showStatusBar; }
set{ showStatusBar = value; }
} public AppSettings()
{
// Create default application settings.
aspectRatio = 1.3333F;
lookupDir = @"C:\AppDirectory";
autoSaveTime = 30;
showStatusBar = false; if(File.Exists(fileName))
{
BinaryReader binReader =
new BinaryReader(File.Open(fileName, FileMode.Open));
try
{
// If the file is not empty,
// read the application settings.
// Read 4 bytes into a buffer to
// determine if the file is empty.
byte[] testArray = new byte[3];
int count = binReader.Read(testArray, 0, 3); if (count != 0)
{
aspectRatio = binReader.ReadSingle();
lookupDir = binReader.ReadString();
autoSaveTime = binReader.ReadInt32();
showStatusBar = binReader.ReadBoolean();
}
} // If the end of the stream is reached before reading
// the four data values, ignore the error and use the
// default settings for the remaining values.
catch(EndOfStreamException e)
{
Console.WriteLine("{0} caught and ignored. " +
"Using default values.", e.GetType().Name);
}
finally
{
binReader.Close();
}
} } // Create a file and store the application settings.
public void Close()
{
using(BinaryWriter binWriter =
new BinaryWriter(File.Open(fileName, FileMode.Create)))
{
binWriter.Write(aspectRatio);
binWriter.Write(lookupDir);
binWriter.Write(autoSaveTime);
binWriter.Write(showStatusBar);
}
}
}