Hi ,
I wrote the following code in c++ (native) to get file size:
int o_get_file_leng th(const char * filename)
{
ifstream f (filename, ios::binary );
f.seekg (0, ios::end );
int length = f.tellg ();
f.close();
return length;
}
Is this ok, or is there a better way to get the file size?
Regards,
-Ab. 3 1047
> Hi , I wrote the following code in c++ (native) to get file size:
int o_get_file_leng th(const char * filename) { ifstream f (filename, ios::binary ); f.seekg (0, ios::end ); int length = f.tellg (); f.close(); return length;
}
You could use the stat or _fstat functions.
--
Kind regards,
Bruno. br************* *********@hotma il.com
Remove only "_nos_pam"
Win32 API (although I know I should be talking about .NET here) has a
GetFileSize API. The one advantage of this is that it is capable of
reporting file sizes larger than 4Gb, because it uses two DWORDs for the
result. If you're not dealing with huge files then this is not an issue of
course, and I'd recommend stat as previously advised.
Kevin
"Bruno van Dooren" <br************ **********@hotm ail.com> wrote in message
news:E3******** *************** ***********@mic rosoft.com... Hi , I wrote the following code in c++ (native) to get file size:
int o_get_file_leng th(const char * filename) { ifstream f (filename, ios::binary ); f.seekg (0, ios::end ); int length = f.tellg (); f.close(); return length;
}
You could use the stat or _fstat functions.
--
Kind regards, Bruno. br************* *********@hotma il.com Remove only "_nos_pam"
Thanks for the reply to all. Win32 API (although I know I should be talking about .NET here) has a
I'm doing it in native pure c++, not using .net anywhere.
GetFileSize API. The one advantage of this is that it is capable of
Thanks for the winapi too.
Abubakar.
"Kevin Frey" <ke**********@h otmail.com> wrote in message
news:em******** ******@TK2MSFTN GP11.phx.gbl... Win32 API (although I know I should be talking about .NET here) has a GetFileSize API. The one advantage of this is that it is capable of reporting file sizes larger than 4Gb, because it uses two DWORDs for the result. If you're not dealing with huge files then this is not an issue of course, and I'd recommend stat as previously advised.
Kevin
"Bruno van Dooren" <br************ **********@hotm ail.com> wrote in message news:E3******** *************** ***********@mic rosoft.com... Hi , I wrote the following code in c++ (native) to get file size:
int o_get_file_leng th(const char * filename) { ifstream f (filename, ios::binary ); f.seekg (0, ios::end ); int length = f.tellg (); f.close(); return length;
}
You could use the stat or _fstat functions.
--
Kind regards, Bruno. br************* *********@hotma il.com Remove only "_nos_pam"
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: middletree |
last post by:
How do I request the actual page name that I'm on? This is going to go into
an include file, and depending on which page I'm on, I'd like to do
different things. I'm looking for "pagename.asp"
|
by: PlanarIndia |
last post by:
hi,
I am facing an issue with getting the file size of a network shared file. I
tried using FileInfo.length and it is returning me size that is rounded off
to the nearest 1024 bytes. E.g. for a file of size 900 bytes,
FileInfo.lenght returns me 1024.
Using native GetFileSize also showed the same behaviour.
Is there any way to find the correct size of a network shared file?
|
by: Arnold |
last post by:
Is using fseek and ftell a reliable method of getting the file size on a
binary file? I thought I remember reading somewhere it wasn't... If not what
would be the "right" and portable method to obtain it? Thanks.
|
by: KarimL |
last post by:
Thanks for your advices...
but i need to get the Image height because i dynamically resize the height
of my webcontrol based on the image height.
More i just have the url (relative parth) to the the image but in design
time mode all variables concerning Server or Context
ar not set ! ...so I can't use MapPath function to obtain the physical
parth of the picture ...
So my second question is how to retrieve the
physical root path of the...
|
by: ruju00 |
last post by:
I am getting an error in Login() method of the following class
FtpConnection
public class FtpConnection
{
public class FtpException : Exception
{
public FtpException(string message) : base(message){}
public FtpException(string message, Exception innerException) :
base(message,innerException){}
| |
by: leonard.guillaume |
last post by:
Hi guys,
I use dynamic char arrays and I'm trying to get rid of the garbage in
it. Let me show you the code and then I'll explain more in details.
----------------------------------------------------------------------------------------------------
CFile oFile("User.tcx", CFile::modeRead);
CRijndael oDecrypt;
long size;
char* buffer,* buf;
|
by: AshishMishra16 |
last post by:
HI friends,
I am using the Flex to upload files to server. I m getting all the details about the file, but I m not able to upload it to Server. Here is the code i m using for both flex & for Struts:
import java.io.File;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.Iterator;
|
by: Catalyst159 |
last post by:
I have a form which is used to calculate residential Floor Area Ratio (FAR). The form is structured into seven parts as follows:
Part A: Maximum FAR and Floor Area:
Part B: Gross Floor Area of the main floors of the main house:
Part C: Gross Floor Area of the basement or cellar:
Part D: Gross Floor Area of the attic:
|
by: vikas251074 |
last post by:
I am not getting date value in spite of my good effort. This code was working in my last office where I work. Now I am trying to work at my home pc. but not getting date value. Any can help me why this happens. This is my part of code given below.
<%@ Language=VBScript%>
<%Option Explicit%>
<html>
<head>
<title>SABF</title>
<!--#include file="font.css"-->
|
by: vikas251074 |
last post by:
I am getting error above in following code since few days giving tension day and night.
How can I solve this? I am facing since Oct.25. in line no. 362
After doing a lot of homework, I am surrendered to you.
<%@ Language=VBScript%>
<%Option Explicit%>
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |