如何在C#中获取文件的crc32和文件的比例.... [英] How can get crc32 of files in C# and proporties of file....

查看:250
本文介绍了如何在C#中获取文件的crc32和文件的比例....的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何以c#和文件比例获取文件的crc32 ....



我尝试过:



我在google上找了好几件东西但我找不到任何东西........

解决方案

< blockquote>这有三个部分:

1)读取文件内容。

2)计算你读取的字节的CRC32。

3)获取文件属性。



第一个是微不足道的:

  byte  [] data = File.ReadAllBytes(pathToFile); 



第二个更复杂,但这应该会有所帮助:如何计算C#中的CRC [ ^ ]



最后一部分又是微不足道的,只需使用 FileInfo类(System.IO) [ ^ ]:

 FileInfo fi =  new  FileInfo(pathToFile); 


你应该回到C / C ++基础知识

C编程语言 - 维基百科,免费的百科全书 [ ^ ]

https://hassanolity.files.wordpress.com/2013/11/the_c_programming_language_2.pdf [ ^ ]

http://www.ime.usp.br/~pf/Kernighan-Ritchie/C-Programming-Ebook.pdf [ ^ ]



引用:

我必须读取哪种格式的文件?

这个cote让我们想一想你跳过了一些基本原理。这个问题毫无意义。



我知道链接不是C#,而C#来自C来自C ++。


How can get crc32 of files in c# and proporties of file....

What I have tried:

I have looked for several things on the google but i cannot find anything........

解决方案

There are three parts to this:
1) Read the file content.
2) Calculate the CRC32 of the bytes you read.
3) Get file properties.

The first is trivial:

byte[] data = File.ReadAllBytes(pathToFile);


The second is more complex, but this should help: How to calculate a CRC in C#[^]

The final part is trivial again, just use the FileInfo Class (System.IO)[^]:

FileInfo fi = new FileInfo(pathToFile);


You should come back to C/C++ basics
The C Programming Language - Wikipedia, the free encyclopedia[^]
https://hassanolity.files.wordpress.com/2013/11/the_c_programming_language_2.pdf[^]
http://www.ime.usp.br/~pf/Kernighan-Ritchie/C-Programming-Ebook.pdf[^]

Quote:

I have to read the file which format?

This cote let us think that you skipped some of the fundamentals. The question makes no sense.

I know the links are not C#, but C# comes from ++ which comes from C.


这篇关于如何在C#中获取文件的crc32和文件的比例....的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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