How to get the file size number?
Hrcko 9 3866
Hrvoje Voda,
I believe there is more than one way to do that, but check out
FileInfo.Length proeprty.
--
HTH
Stoitcho Goutsev (100)
"Hrvoje Voda" <hr*********@luatech.com> wrote in message
news:ds**********@ss405.t-com.hr... How to get the file size number?
Hrcko
Hello, Hrvoje!
HV> How to get the file size number?
HV> Hrcko
FileInfo fInfo = new FileInfo(filePath);
Console.WriteLine("File size is: " + fInfo.Length.ToString());
--
Regards, Vadym Stetsyak
www: http://vadmyst.blogspot.com
"Hrvoje Voda" <hr*********@luatech.com> wrote in message
news:ds**********@ss405.t-com.hr... How to get the file size number?
You can use System.IO.FileInfo.Length
/Anders
It works, but I want to get a value in KB.
Example, I get 8745 bytes, but I also want to get a value in KB.
"Stoitcho Goutsev (100)" <10*@100.com> wrote in message
news:Ox**************@TK2MSFTNGP10.phx.gbl... Hrvoje Voda, I believe there is more than one way to do that, but check out FileInfo.Length proeprty.
-- HTH Stoitcho Goutsev (100)
"Hrvoje Voda" <hr*********@luatech.com> wrote in message news:ds**********@ss405.t-com.hr... How to get the file size number?
Hrcko
So divide by 1000 or 1024 depending on your local interpretation of KB...
Marc
Hello, Hrvoje!
divide the size on 1024
int kbSize = fileInfo.Length / 1024;
--
Regards, Vadym Stetsyak
www: http://vadmyst.blogspot.com
I don't get a decimal number, just rounded number.
For example, number is 8735, and I want to get 8,735.
"Vadym Stetsyak" <va*****@ukr.net> wrote in message
news:OW**************@TK2MSFTNGP14.phx.gbl... Hello, Hrvoje!
divide the size on 1024
int kbSize = fileInfo.Length / 1024;
-- Regards, Vadym Stetsyak www: http://vadmyst.blogspot.com
Due to internationalisation, I'm not 100% sure whether you mean "8 <thousand
separator> 735" or "8 <decimal point> 735"
For the former, something like fileSize.ToString("###,###,##0"); might help
For the latter, try fileSize / 1000F;
Hope this helps,
Marc
Hrvoje Voda <hr*********@luatech.com> wrote: I don't get a decimal number, just rounded number.
For example, number is 8735, and I want to get 8,735.
That's because unless you specify anything different, C# will divide
one integer by another in an integer way.
You can use fileSizeInBytes / 1024.0 to get a binary floating point
number, or fileSizeInBytes / 1024m to get a decimal.
--
Jon Skeet - <sk***@pobox.com> http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Dave Smithz |
last post by:
Hi There,
I have a PHP script that sends an email with attachment and works great when
provided the path to the file to send.
However this file needs to be on the same server as the script.
...
|
by: M P |
last post by:
Can you help me find an asp code that will upload a file from my PC to web
server?
Mark
|
by: Skc |
last post by:
I have a .txt which has been exported as a .csv from an external source.
What i need to do is to import this into SQL2000 (into a table) but I need to
do special things on the data:
1. I need to...
|
by: Lokkju |
last post by:
I am pretty much lost here - I am trying to create a managed c++
wrapper for this dll, so that I can use it from c#/vb.net, however, it
does not conform to any standard style of coding I have seen....
|
by: BW |
last post by:
I am creating an upload/download function for an extranet site. Files will
be uploaded to directory based upon the users login and associated project.
The function works as long as I use "c:\Temp"...
|
by: Dan |
last post by:
Hi,
I know this code is not entirely javascript, but bare with me. Can you
please tell me why this does not work:
page: filemanager.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0...
|
by: j7.henry |
last post by:
I am trying to pull specific data that is in a comma delimited file
into a web page. So if my comma delimited file looks like:
Name,Address,Zip
Fred,123 Elm,66666
Mike,23 Jump,11111
I would...
|
by: forest demon |
last post by:
for example, let's say I do something like,
System.Diagnostics.Process.Start("notepad.exe","sample.txt");
if the user does a SaveAs (in notepad), how can i capture the path that
the user...
|
by: cleary1981 |
last post by:
Hi, I have created a script in PHP thats generates an SVG image. Want I want to do is have PHP save this as example.svg. Can this be done? Heres my code
<?php
require "config.php";
$proj_id =...
|
by: premprakashbhati |
last post by:
hi, good evening..
i am going to upload an image in a web form .....for that iam using HTML input(file) control and one web control button i.e., Upload_Button()
here is the code ...its work fine...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
| |