Главная страница
    Top.Mail.Ru    Яндекс.Метрика
Форум: "Основная";
Текущий архив: 2005.09.18;
Скачать: [xml.tar.bz2];

Вниз

Копирование файлов   Найти похожие ветки 

 
Scorpio ©   (2005-08-26 16:57) [0]

Добрый день мастера. Подскажите плиз каким способом можно скопировать файл, а то тот мой не очень это делает.

var    Streaml, stream2: TFileStream;

try
       Streaml := TFileStream.Create(pat1+"\nomer.dbf", fmOpenRead);
       Stream2 := TFileStream.Create(pat+"\nomer1.dbf", fmCreate);
       Stream2.Seek(0, soFromEnd);
       Stream2.CopyFrom(Streaml, Streaml.Size);
 
 finally
           Stream2.Free;
           Streaml.Free;
    end;

Вообщето он работает но конда к этот файл используют другие, то он выкидывает ошибку.


 
Fay ©   (2005-08-26 16:58) [1]

2 Scorpio ©   (26.08.05 16:57)
CopyFile ?


 
Плохиш ©   (2005-08-26 17:13) [2]


> Вообщето он работает но конда к этот файл используют другие,
> то он выкидывает ошибку.

Какой из двух файлов используют?
fmOpenRead + fmShareDenyNone?


 
Scorpio ©   (2005-08-26 17:17) [3]

А точную структуру можно, а то я как только не писал, он только ошибки кидает.
MoveFile работает, а CopyFile не получается


 
Scorpio ©   (2005-08-26 17:19) [4]

используют тот который я открываю.


 
Плохиш ©   (2005-08-26 17:22) [5]


> Scorpio ©   (26.08.05 17:19) [4]
> используют тот который я открываю.

Во, гады, а не пробовал применить административные меры? А то тебе файл нужен, а они используют.


 
Scorpio ©   (2005-08-26 17:28) [6]

Так проблема в том, что с ним работают постоянно. Ведб ТОТАЛКОМАНДЕР же как то его копирует, как мне повторить его операцию


 
Fay ©   (2005-08-26 17:30) [7]

Scorpio ©   (26.08.05 17:28) [6]
Ты CopyFile пробовал? Или нет?


 
Игорь Шевченко ©   (2005-08-26 17:33) [8]

Есть предположение, что Total Commander работает через вызов функции CreateFile :)

Плохиш ©   (26.08.05 17:13) [2]


> fmOpenRead + fmShareDenyNone?


dwShareMode
[in] Sharing mode of the object (reading, writing, both, or neither). You cannot request a sharing mode that conflicts with the access mode specified in a previous open request whose handle is still open. Doing so would result in a sharing violation (ERROR_SHARING_VIOLATION).


 
Scorpio ©   (2005-08-26 17:37) [9]

Для COPYFILE у меня в дельфе нет к ней описания, пробовал по аналогии с MOVEFILE не получается. Подскажите, как использовать COPYFILE.


 
Fay ©   (2005-08-26 17:39) [10]

The CopyFile function copies an existing file to a new file.

The CopyFileEx function provides two additional capabilities. CopyFileEx can call a specified callback function each time a portion of the copy operation is completed, and CopyFileEx can be canceled during the copy operation.

BOOL CopyFile(
 LPCTSTR lpExistingFileName, // name of an existing file
 LPCTSTR lpNewFileName,      // name of new file
 BOOL bFailIfExists          // operation if file exists
);
Parameters
lpExistingFileName
[in] Pointer to a null-terminated string that specifies the name of an existing file.
Windows NT/2000/XP: In the ANSI version of this function, the name is limited to MAX_PATH characters. To extend this limit to nearly 32,000 wide characters, call the Unicode version of the function and prepend "\\?\" to the path. For more information, see File Name Conventions.

Windows 95/98/Me: This string must not exceed MAX_PATH characters.

lpNewFileName
[in] Pointer to a null-terminated string that specifies the name of the new file.
Windows NT/2000/XP: In the ANSI version of this function, the name is limited to MAX_PATH characters. To extend this limit to nearly 32,000 wide characters, call the Unicode version of the function and prepend "\\?\" to the path. For more information, see File Name Conventions.

Windows 95/98/Me: This string must not exceed MAX_PATH characters.

bFailIfExists
[in] Specifies how this operation is to proceed if a file of the same name as that specified by lpNewFileName already exists. If this parameter is TRUE and the new file already exists, the function fails. If this parameter is FALSE and the new file already exists, the function overwrites the existing file and succeeds.
Return Values
If the function succeeds, the return value is nonzero.

If the function fails, the return value is zero. To get extended error information, call GetLastError.

Remarks
Security attributes for the existing file are not copied to the new file.

File attributes for the existing file are copied to the new file. For example, if an existing file has the FILE_ATTRIBUTE_READONLY file attribute, a copy created through a call to CopyFile will also have the FILE_ATTRIBUTE_READONLY file attribute.

Windows 95/98/Me: CopyFileW is supported by the Microsoft Layer for Unicode. To use this, you must add certain files to your application, as outlined in Microsoft Layer for Unicode on Windows 95/98/Me Systems.

Windows 2000: When CopyFile is used to copy an encrypted file, the function attempts to encrypt the destination file with the default keys. No attempt is made to encrypt the destination file with the keys used in the encryption of the source file. If it cannot be encrypted, CopyFile completes the copy operation without encrypting the destination file.

Windows XP: When CopyFile is used to copy an encrypted file, it attempts to encrypt the destination file with the keys used in the encryption of the source file. If this cannot be done, this function attempts to encrypt the destination file with default keys, as in Windows 2000. If both of these methods cannot be done, CopyFile fails with an ERROR_ENCRYPTION_FAILED error code.

Example Code
For an example, see Searching for Files and Changing File Attributes.

Requirements
 Windows NT/2000/XP: Included in Windows NT 3.1 and later.
 Windows 95/98/Me: Included in Windows 95 and later.
 Header: Declared in Winbase.h; include Windows.h.
 Library: Use Kernel32.lib.
 Unicode: Implemented as Unicode and ANSI versions on Windows NT/2000/XP. Also supported by Microsoft Layer for Unicode.


 
Fay ©   (2005-08-26 17:41) [11]

Короче,
if CopyFile(PChar(pat1+"\nomer.dbf")m PChar(pat+"\nomer1.dbf"), False) then
 RaiseLastOsError;


 
Игорь Шевченко ©   (2005-08-26 17:46) [12]

Fay ©   (26.08.05 17:41) [11]

if not


 
Fay ©   (2005-08-26 17:51) [13]

2 Игорь Шевченко ©   (26.08.05 17:46) [12]
Ну бывает 8). А ещё там вместо запятой какая-то фигня стоит.
Думаю, что для вооружённого кнопкой F1 человека это не помеха.


 
Scorpio ©   (2005-08-26 18:08) [14]

Вся проблема в том что у меня в D7 нет ничего про COPYFILE, а то что мне дали оно очень даже работает. всем спасибо. :))


 
Fay ©   (2005-08-26 18:12) [15]

2 Scorpio ©   (26.08.05 18:08) [14]
Delphi7.Меню->Help->Microsoft SDK есть?


 
Scorpio ©   (2005-08-26 18:24) [16]

вижу, никогда не знал про него. СПАСИБО.



Страницы: 1 вся ветка

Форум: "Основная";
Текущий архив: 2005.09.18;
Скачать: [xml.tar.bz2];

Наверх





Память: 0.49 MB
Время: 0.012 c
14-1124136607
Almaz
2005-08-16 00:10
2005.09.18
А как насчет SPbMP ?


14-1124687175
rentgen
2005-08-22 09:06
2005.09.18
Кому не сложно прокоментировать оформление программы?


1-1124949328
Darkwing
2005-08-25 09:55
2005.09.18
Может ли свойство возвращать разные типы данных?


8-1115289314
BasiL_666_
2005-05-05 14:35
2005.09.18
помогите хоть чемнибудь.....


6-1117311765
Arty
2005-05-29 00:22
2005.09.18
Indy IdTCPDemo





Afrikaans Albanian Arabic Armenian Azerbaijani Basque Belarusian Bulgarian Catalan Chinese (Simplified) Chinese (Traditional) Croatian Czech Danish Dutch English Estonian Filipino Finnish French
Galician Georgian German Greek Haitian Creole Hebrew Hindi Hungarian Icelandic Indonesian Irish Italian Japanese Korean Latvian Lithuanian Macedonian Malay Maltese Norwegian
Persian Polish Portuguese Romanian Russian Serbian Slovak Slovenian Spanish Swahili Swedish Thai Turkish Ukrainian Urdu Vietnamese Welsh Yiddish Bengali Bosnian
Cebuano Esperanto Gujarati Hausa Hmong Igbo Javanese Kannada Khmer Lao Latin Maori Marathi Mongolian Nepali Punjabi Somali Tamil Telugu Yoruba
Zulu
Английский Французский Немецкий Итальянский Португальский Русский Испанский