“System.Diagnostics”中的“FileVersionInfo.GetVersionInfo”功能如何工作?! [英] How 'FileVersionInfo.GetVersionInfo' function in 'System.Diagnostics' Works?!

查看:369
本文介绍了“System.Diagnostics”中的“FileVersionInfo.GetVersionInfo”功能如何工作?!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

基本上我需要在FTP服务器目录中阅读文件的产品版本。

但是这个函数对我来说没用,如果函数在后台下载文件然后读取信息,基本上如果这个函数只是直接从FTP目录中读取产品信息而没有任何首先下载文件然后阅读版本,那么我才能使用它。



所以,如果你知道,这个函数是如何工作的,你可以解释几个步骤,因为我不知道如何看到函数的代码。



我用的简单代码是这样的:

Basically I need to read the product version of a file in FTP server directory.
But this function will be no use for me, if the function downloads the file in background and then reads the info, basically if this function only read the product info directly from the FTP directory without any kind of first downloading the file then reading the version, only then i can use it.

So can you explain few steps if you know, how this function really works, since I dont know how to see the code of the function.

simple code i use is this:

var FileVer = System.Diagnostics.FileVersionInfo.GetVersionInfo(ftpListItem.FullName);
string x = FileVer.ProductVersion;

推荐答案

实际上,如果您从任何文件中读取任何数据,则需要将该数据加载到内存中。因此,对于存储是至关重要的是非常无动于衷。

如果你想知道它是如何工作的,请阅读代码: http://referencesource.microsoft.com/#System/services/monitoring/system/diagnosticts/FileVersionInfo.cs [ ^ ]。



通常,版本信息首先来自嵌入式资源,这些资源存储在文件末尾。因此,首先您需要文件的标题才能计算资源的位置。你可以跳到那个位置 - 如果可以的话。并非所有FTP服务器都实现此功能。



无论如何,您需要至少下载文件的某些部分...
Practically, if you read any data from any file, you need to load that data in the memory. So it is quite indifferent what storage is benieth.
If you want to know how it really works, read the code: http://referencesource.microsoft.com/#System/services/monitoring/system/diagnosticts/FileVersionInfo.cs[^].

In general, version informations are first from the embedded resources, which are stored at the end of the file. So, first you will need the headers of the file to be able to calculate the position of the resources. Than you can skip to that positions - if you can. As not all FTP servers implement this feature.

Anyway, you will need to download at least some portions of the file...


这篇关于“System.Diagnostics”中的“FileVersionInfo.GetVersionInfo”功能如何工作?!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆