Datei öffnen / Informationen auslesen
-
ich bin mir nicht so sicher wie du das meinst. Willst du vieleicht ein "Öffnen"-Dialog?
klenes Beispiel.
CFileDialog m_ldFile(TRUE); double m_dLdFileGroesse; /* Variable fuer File-Groesse */ // Festlegen, dass die File einen bestimmten Datei-Typ entsprechen soll m_ldFile.m_ofn.lpstrDefExt = "jpg"; /* Bin mir aber auch nicht sicher müsstest du mal ausprobieren */ if (m_ldFile.DoModal() == IDOK) { /* * Hier kommt jetzt dein Teil hin, wo du die File Groesse * bestimmst --- wie das geht habe ich keine Ahnung. */ }Vieleicht ist das ein kleiner Ansatz.
Ich weis nicht ob ich dir damit helfen konnte - oder ob das überhaubt dein Problem ist
mfg, the flyingCoder.
-
CKrause schrieb:
Hi Leute!
. Die Methoden CFile::Open, CreateFile, und fopen funzten bei mir nicht.
ChristianWas funktioniert da nicht ?
-
Die Datei wird von FtpGetFile explizit geöffnet sein.
-
@deus: Mir ist klar, dass die Datei geöffnet ist, aber wenn ich in Windows diese Datei mit der rechten Maustaste anklicke und auf Eigenschaften gehe, zeigt er mir die momentane Größe, während des Downloads an. Ich denke, dass muss über Tricks doch irgendwie programmatisch lösbar sein. Denke ich.
-
CFile::GetStatus ?
-
von fopen bekomme ich gar keinen Fehler
von CreateFile(); bekomme ich: "Die Netzwerkanforderung wird nicht unterstützt."
von CFile::OpenFile bekomme ich: "The process cannot access the file because it is being used by another process."und CFile::GetStatus bekommt keine Größe rein, die bleibt 0
ich meine etwas anderes
Aber Danke schonmal für eure Mühe!
-
Hi,
was übergibst du FtpGetFile in dwFlagsAndAttributes? Hier kannst du den shareMode einstellen. Hast du das gemacht?
Grüße, Volle.
-
MSDNL sagt: dwLocalFlagsAndAttributes
File attributes for the new file. Can be any combination of the FILE_ATTRIBUTE_* flags used by theCreateFile function. For more information on FILE_ATTRIBUTE_* attributes, see CreateFile in the Platform SDK.da ist doch kein share mode dabei, oder zumindest akzeptiert FtpGetFile FILE_SHARE_READ nicht, sondern nimmt es meiner Meinung nach als FILE_ATTRIBUTE_READONLY, da es dem selben Wert entspricht:
Auszug aus WinNT.h:#define FILE_SHARE_READ 0x00000001 <---
#define FILE_SHARE_WRITE 0x00000002
#define FILE_SHARE_DELETE 0x00000004
#define FILE_ATTRIBUTE_READONLY 0x00000001 <---
#define FILE_ATTRIBUTE_HIDDEN 0x00000002
#define FILE_ATTRIBUTE_SYSTEM 0x00000004
#define FILE_ATTRIBUTE_DIRECTORY 0x00000010Also, ich habs probiert und es geht nicht, oder habe ich was falsch gemacht?
BOOL a = FtpGetFile(hFtp, srcfile, dstfile, TRUE, FILE_SHARE_READ, FTP_TRANSFER_TYPE_BINARY, 0);
-
hat keiner mehr eine Idee?
-
no fucking way?
-
Wenn man in der MSDN genau schaut stellt man fest das es diese Flags für diese Funktion nicht gibt
#define FILE_SHARE_READ 0x00000001 <---
#define FILE_SHARE_WRITE 0x00000002
#define FILE_SHARE_DELETE 0x00000004CFtpConnection::GetFile
BOOL GetFile( LPCTSTR pstrRemoteFile, LPCTSTR pstrLocalFile, BOOL bFailIfExists = TRUE, DWORD dwAttributes = FILE_ATTRIBUTE_NORMAL, DWORD dwFlags = FTP_TRANSFER_TYPE_BINARY, DWORD dwContext = 1 );Return Value
Nonzero if successful; otherwise 0. If the call fails, the Win32 functionGetLastError may be called to determine the cause of the error.
Parameters
pstrRemoteFile
A pointer to a null-terminated string containing the name of a file to retrieve from the FTP server.
pstrLocalFile
A pointer to a null-terminated string containing the name of the file to create on the local system.
bFailIfExists
Indicates whether the file name may already be used by an existing file. If the local file name already exists, and this parameter is TRUE, GetFile fails. Otherwise, GetFile will erase the existing copy of the file.
dwAttributes
Indicates the attributes of the file. This can be any combination of the following FILE_ATTRIBUTE_* flags.
FILE_ATTRIBUTE_ARCHIVE The file is an archive file. Applications use this attribute to mark files for backup or removal.
FILE_ATTRIBUTE_COMPRESSED The file or directory is compressed. For a file, compression means that all of the data in the file is compressed. For a directory, compression is the default for newly created files and subdirectories.
FILE_ATTRIBUTE_DIRECTORY The file is a directory.
FILE_ATTRIBUTE_NORMAL The file has no other attributes set. This attribute is valid only if used alone. All other file attributes override FILE_ATTRIBUTE_NORMAL:
FILE_ATTRIBUTE_HIDDEN The file is hidden. It is not to be included in an ordinary directory listing.
FILE_ATTRIBUTE_READONLY The file is read only. Applications can read the file but cannot write to it or delete it.
FILE_ATTRIBUTE_SYSTEM The file is part of or is used exclusively by the operating system.
FILE_ATTRIBUTE_TEMPORARY The file is being used for temporary storage. Applications should write to the file only if absolutely necessary. Most of the file’s data remains in memory without being flushed to the media because the file will soon be deleted.
dwFlagsSpecifies the conditions under which the transfer occurs. This parameter can be any of the dwFlags values described inFtpGetFile in the Platform SDK.
dwContext
The context identifier for the file retrieval. See Remarks for more information about dwContext.
Remarks
Call this member function to get a file from an FTP server and store it on the local machine.
GetFile is a high-level routine that handles all of the overhead associated with reading a file from an FTP server and storing it locally. Applications that only retrieve file data, or that require close control over the file transfer, should use OpenFile and CInternetFile::Read instead.
If dwFlags is FILE_TRANSFER_TYPE_ASCII, translation of file data also converts control and formatting characters to Windows equivalents. The default transfer is binary mode, where the file is downloaded in the same format as it is stored on the server.
Both pstrRemoteFile and pstrLocalFile can be either partially qualified filenames relative to the current directory or fully qualified. A backslash (\) or forward slash (/) can be used as the directory separator for either name. GetFile translates the directory name separators to the appropriate characters before they are used.
Override the dwContext default to set the context identifier to a value of your choosing. The context identifier is associated with this specific operation of the CFtpConnection object created by its CInternetSession object. The value is returned to CInternetSession::OnStatusCallback to provide status on the operation with which it is identified. See the articleInternet First Steps: WinInet for more information about the context identifier.
CFtpConnection Overview | Class Members | Hierarchy Chart
See Also CInternetConnection
-
ja, sag ich doch