如何使用C#在文本框中打印所选文件的大小? [英] How to print the selected file size in a text box using c#?
本文介绍了如何使用C#在文本框中打印所选文件的大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用.net中的打开文件对话框在文本框中打印了文件名.现在,我想在另一个文本框中打印文件的大小.如何执行此操作.请告诉编码.
谢谢
Hi,
I printed a file name in a textbox by using the open file dialog in .net.Now i want to print it''s size in another textbox.How to do that.kindly tell the coding for that.
Thank you
推荐答案
尝试:
Try:
FileInfo fi = new FileInfo(@"D:\Temp\myFile.txt");
myTextBoxForFileSize.Text = fi.Length.ToString();
如果您想要文件的长度,请尝试以下操作:
Try this if you want the length of file:
FileInfo fInfo = new FileInfo(@"c:\test.txt");
TextBox1.Text = fInfo.Length.ToString();
并检查磁盘上的实际大小:
c-get-file-size-on-disk [ ^ ]
希望对您有所帮助:)
and check this out for actual size on disk:
c-get-file-size-on-disk[^]
hope it helps :)
这篇关于如何使用C#在文本框中打印所选文件的大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文