管理 C# WPF 应用程序客户端 PC 文件夹中的 3000 个文件

发布于 2024-10-17 03:58:11 字数 530 浏览 3 评论 0原文

我想在用户 PC 上为 WPF C# 应用程序创建一个包含大约 3000 个文件的文件夹。我担心实现后,查找文件名是否会太慢。有人可以建议它是否应该工作,或者是否有更好的选择? 基本上,我的主要目标是使用 Clickonce 将应用程序部署在任何用户 PC 上,并启动它运行,而不需要下载数据库应用程序。

背景: 我创建了一个 C# 应用程序来查找 yahoo Finance 中的相关对。目前,它下载 3000 个交易品种的报价并将其存储在用户 PC 上的 Mysql 数据库中。我有兴趣创建一个不依赖于 Mysql 数据库的应用程序的新版本。我正在考虑将所有引号保存在用户 PC 上文件夹中的单独文件中。不确定这是否是一个好主意,或者是否有其他替代方案,例如在用户 PC 上创建小对象数据库,使用一些辅助类库管理大型数组的缓存等将是理想的。

PS:这是一个开源教育项目,所以我买不起商业产品。

I want to create a folder with around 3000 files on a user PC for a WPF C# application. I am worried whether after I implement, if the lookup of a filename will be too slow. Can someone please suggest whether it should work, or if there is a better alternative?
Basically, my main goal is to use Clickonce to deploy the application on any user PC, and start it to run without imposing requirements of downloading database application.

Background:
I have created a C# application to find correlated pairs from yahoo finance. It currently downloads quotes for 3000 symbols and stores it in a Mysql database on the user PC. I am interested in creating a new version of the application which does not depend on Mysql database. I am thinking of saving all the quotes in a separate files in a folder on the user PC.Not sure if this is a good idea, or if some other alternatives like creating small object database on the user PC, using some helper class library which manages cache of large arrays, etc. would be ideal.

PS : It is an open source education project, so I cannot afford to buy commercial product.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

南街九尾狐 2024-10-24 03:58:12

使用 SQLite 怎么样?除了软件之外,您不需要安装任何其他东西。 这是 .NET 的包装器

要回答有关查找驱动器上的文件名的问题,这取决于驱动器的类型。如果它是 SSD,可能根本不需要很长时间,如果它是机械驱动器并且您正在使用索引,它也会很快。但是,如果您不使用索引并且机械驱动器速度较慢,则速度会很慢。

如果您确实想要性能并希望将其存储,您还可以考虑 RAM 磁盘 / RAM 驱动器在文件系统上。但是,您还需要将其存储在持久存储中。

How about using SQLite? You wouldn't need to install anything else than your software. Here is a wrapper for .NET.

To answer your question regarding looking up the filename on the drive, that depends on what kind of drive it is. If it is an SSD it will probably not take long at all, if it is a mechanical drive and you are using indexing it will also be fast. However if you don't use indexing and have a slower mechanical drive, it will be slow.

You could also consider a RAM Disk / RAM Drive if you really want performance and want to have it stored on a filesystem. However, you would need to store it on a persistant storage as well.

何时共饮酒 2024-10-24 03:58:12

您可以使用简单的基于文件的数据库,例如 SQLite。

http://www.sqlite.org/

还有一个 .NET 驱动程序。

http://code.google.com/p/csharp-sqlite/

You could use a simple file-based database such as SQLite.

http://www.sqlite.org/

There is a .NET driver for it as well.

http://code.google.com/p/csharp-sqlite/

乙白 2024-10-24 03:58:12

在这种情况下,我不建议回退到文件系统来代替数据库。您是否考虑过 SQL Server Compact EditionSQLite?两者都在进程内运行,这意味着您不必安装数据库服务器 - 它是应用程序的一部分。当然,它们仍然支持 SQL。

I wouldn't advise falling back to the file system in lieu of a database in this case. Have you considered SQL Server Compact Edition or SQLite? Both run in-process, meaning that you don't have to install a database server - it's part of your application. And, of course, they still support SQL.

故事未完 2024-10-24 03:58:12

3000 个文件就可以了,300,000 个文件就会有问题了:)

唯一确定的方法就是测量!

创建包含 10 个零长度文件、100 个文件和 1000 个文件的文件夹。 。 。 10,000,000。

然后测量在每个文件夹中查找文件所需的时间,您将更好地了解哪些文件夹“太慢”。

PS“太慢”完全是主观的。 10毫秒太慢,还是10分钟太慢?

您需要确定什么是“太慢”并从那里开始工作。

PPS 在决定以这种方式使用文件系统之前请仔细考虑,还有更好的替代方案(如其他分析中所示)。

3000 files will be fine, 300,000 files and you'd have a problem :)

The only way to know for sure is to measure!

Create folders with 10 zero length files , 100 files 1000 files . . . 10,000,000.

Then measure the time it takes to find a file in each of the folders, you'll get a better idea which are "too slow".

P.s. "Too slow" is completely subjective. is 10ms too slow, or is 10 miunutes too slow?

You need to decide what "Too slow" is and work from there.

P.P.S Think carefully before deciding to use the file system in this way, there are better alternatives (as shown in other anawers).

江城子 2024-10-24 03:58:12

我建议考虑使用 XML 文件来存储 3000 对数据,而不是 3000 个单独的文件,并且您可以使用大量 LINQ to XML 来更快地访问数据。

I would say consider using a XML file to store your 3000 pairs of data, rahter than 3000 separate files, and there are plenty of LINQ to XML you can use to access data faster.

暗喜 2024-10-24 03:58:11

我建议使用(正如您所说,您愿意考虑文件系统的替代方案)Sql Server Compact 4.0。它是:

  • 轻量级
  • 不需要运行单独的安装程序
  • 不需要运行单独的服务
  • 内存占用少
  • 非常容易编写代码,因为您可以使用 DataTableDataSet< /code> 和一组非常熟悉的基于 SqlServerCe 的 SqlConnection / SqlDataAdapter 类。
  • 免费
  • 如果您需要的话,这是将来升级到 Sql Server Express 的良好选择。
  • 有可用的工具(在 Webmatrix 中,我认为 Visual Studio 2010 SP1),允许您操作数据库结构而无需求助于代码。

您可能能够在很短的时间内实现交换,因为“大部分”工作可以通过向项目中添加对 SqlServerCe 的引用并执行搜索和搜索来完成。将“MySql”替换为“SqlServerCe”。这有点过于简单化了,但也不是太多! =)

I'd recommend using (as you've said that you're willing to look at alternatives to the file system) Sql Server Compact 4.0. It's:

  • Lightweight
  • Doesn't require a separate installer to be run
  • Doesn't need a separate service to be running
  • Light on memory footprint
  • Very easy to code against as you can use DataTable, DataSet and a set of SqlServerCe based SqlConnection / SqlDataAdapter classes that will be very familiar.
  • Free!
  • A good candidate for upgrading to Sql Server Express in the future if you need to.
  • Has tooling available (in Webmatrix, and I think Visual Studio 2010 SP1) that allows you to manipulate the database structure without having to resort to code.

You'll probably be able to achieve a swap-over in a very short space of time as "most" of the work can be achieved by adding a reference to SqlServerCe to your project and performing a search & replace on "MySql" for "SqlServerCe". That's a slight oversimplification, but not by much! =)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文