M Mashao Rakgole May 22, 2007 #1 In C#, How does one get the file size of a given text file? BR Mashao
E Erik Molenaar May 22, 2007 #2 You can use System.IO.FileInfo example: System.IO.FileInfo fileInfo = new System.IO.FileInfo(@"c:\getmysize.txt"); // write file length in bytes to textbox1 this.textBox1.Text = fileInfo.Length.ToString(); Hope this helps, Erik
You can use System.IO.FileInfo example: System.IO.FileInfo fileInfo = new System.IO.FileInfo(@"c:\getmysize.txt"); // write file length in bytes to textbox1 this.textBox1.Text = fileInfo.Length.ToString(); Hope this helps, Erik
I Ignacio Machin \( .NET/ C# MVP \) May 22, 2007 #3 Hi, You can get the size of any file by using FileInfo.Length
? =?ISO-8859-1?Q?G=F6ran_Andersson?= May 22, 2007 #4 Mashao said: In C#, How does one get the file size of a given text file? Click to expand... To get the size in bytes, you use the Length property of the FileInfo class, as others already have mentioned. If you want to know the size in characters, you have to read the file and decode the bytes into characters to find out the size.
Mashao said: In C#, How does one get the file size of a given text file? Click to expand... To get the size in bytes, you use the Length property of the FileInfo class, as others already have mentioned. If you want to know the size in characters, you have to read the file and decode the bytes into characters to find out the size.