c#通过索引打开文件-Metastock数据文件 [英] c# open files through index - metastock data files
问题描述
大家好,
我正在寻求有关在程序中打开文件的帮助.要打开数据文件,我通常会使用OpenFileDialog()和FileStream(),效果很好,但是...
我正在尝试加载一些元数据数据文件,但它们由名为master.dat的文件索引. Master.dat是我已经解析出的旧格式,它提供了目录中其他文件(F * .dat)表示的索引.然后,我可以打开正确的F * .dat并检索O,H,L,C数据.但这是到达我想要的地方的两步过程.
例子...第一次打开目录->
F1.dat
F2.dat
.
.
F50.dat
Master.dat
-我必须先打开Master.dat才能找到我要查找的F * .dat.我解析Master.dat的方式看起来像这样(不一定按字母顺序.
文件名,股票代号,长名称,第一个数据,最后一个数据
F1.dat,MSFT,Microsoft,24/9/1999、27/9/2010
F2.dat,CAM,Cameron Ent,1/1/2005,27/9/2010
.
.
F50.dat,APPL,Apple Comp,24/9/1999、27/9/2010
然后,我打开相应的F * .dat文件以获取所需的数据.
我想做的是让OpenFileDialog自动打开Master.dat文件,然后列出上面显示的内容(通常在该位置看到这些文件),然后我可以直接打开所需的原始文件.我已经整理出索引代码,我只需要打开目录并自动加载master.dat即可显示索引,而不是实际的文件名.
在此先感谢
Flatstrap
Hi all,
I''m chasing some help with opening files in my program. To open a data file I would normally use OpenFileDialog() and FileStream() which works great but...
I am trying to load some metastock data files but they are indexed by a file called master.dat. Master.dat is in an old format which I have parsed out and it gives an index of what the other files (F*.dat) represent in the directory. I can then go and open the correct F*.dat and retrieve the O,H,L,C data. But this is a two step process to get to where I want.
Example... open the directory the first time->
F1.dat
F2.dat
.
.
F50.dat
Master.dat
- I have to open Master.dat first to find out which F*.dat I''m looking for. The way I parsed out Master.dat looks something like this (not necessarily in alphabetical order.
Filename, Ticker, Long Name, First Data, Last Data
F1.dat, MSFT, Microsoft, 24/9/1999, 27/9/2010
F2.dat, CAM, Cameron Ent, 1/1/2005, 27/9/2010
.
.
F50.dat, APPL, Apple Comp, 24/9/1999, 27/9/2010
I then go and open the corresponding F*.dat file to get the data I want.
What I''d like to do is have the OpenFileDialog automatically open the Master.dat file and then list the contents shown above where I''d normally see the files, I can then directly open the stock file I want. I''ve sorted out the indexing code I just need someway of opening a directory and the master.dat loading automatically to show the index, not the actual file names.
Thanks in advance
Flatstrap
推荐答案
我认为您无法获得OpenFileDialog
来做到这一点.
您可以做的是创建自己的对话框,如果需要的话,可以模仿OFD的外观,其中可能包含显示Master.dat内容的ListBox
或ListView
.
然后处理doubleclick事件以加载被单击的F * .dat文件.
I do not think that you can get theOpenFileDialog
to do that.
What you can do is create your own dialog, mimic the appearance of OFD if you want, probably containing aListBox
orListView
that would display the contents of Master.dat.
Then handle the doubleclick event to load the F*.dat file that was clicked.
这篇关于c#通过索引打开文件-Metastock数据文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!