wpw_wapi_file_95.html

来自「VC programing」· HTML 代码 · 共 52 行

HTML
52
字号
<HTML>
<HR><A NAME=WINAPI_FILE_PATH>
Return to <a href="wpw_wapi_index.html#TOC">Table of Contents for this chapter</a><br>
<H4>Subject: Getting the path of file</H4><PRE>
In article <DAt2xt.2EH@mv.mv.com>, kvk@shangri-la.mv.com says...
>
>How can I get a file's full path?  I want to find out from which
>directory my program is running from.

GetModuleFileName() is the go, sunshine.

</PRE>


<HR><A NAME=WINAPI_FILE_SIZE>
Return to <a href="wpw_wapi_index.html#TOC">Table of Contents for this chapter</a><br>
<H4>Subject: Getting the size of a file</H4><PRE>
<andrew@cobra.path.monash.edu.au> wrote:

>How do I et the length of a file on a disk?
>Do I have to open it (in order to get a file handle) and then get the 
>file length of this handle?
>Or is their a faster more efficient way to do this?

        If you are using MFC then check out the function CFile::GetStatus
        else use the stat function

        Rajen Narurkar
<HR>
Once upon a time, <andrew@cobra.path.monash.edu.au> wrote:

>How do I et the length of a file on a disk?
>Do I have to open it (in order to get a file handle) and then get the 
>file length of this handle?
>Or is their a faster more efficient way to do this?


If the file is open, you can use the filelength() function.
"The return value of the filelength() function is the full length of
the file in bytes, including any EOF characters. The return value
returns the same file size value as the DIR command from the MS-DOS,
OS/2, or Windows NT prompt."

If it's not open, you can use the _stat() function, which returns a
structure of information about the named file, including the size.


___________________________________________________________
Marty Fried - mfried@linex.com  |   Press Enter to Exit
San Anselmo, CA                 |          -NT message
(MSVC + MFC) && Win95;        

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?