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

Вниз

Есть способ удаления файлов с аттрибутом readonly?   Найти похожие ветки 

 
novill ©   (2007-01-26 15:30) [0]

Или только после снятия аттрибута?


 
Плохиш ©   (2007-01-26 15:40) [1]

А чем этот способ не нравиться?


 
Vlad Oshin ©   (2007-01-26 15:44) [2]

перепиши стандартное удаление на удаление с предварительным сбросом атрибута


 
novill ©   (2007-01-26 15:58) [3]

Сделал уже.

Пока искал способы, нашел вот такую штуку.

МСДН:
Scripting Runtime Library  

DeleteFile MethodSee Also
CopyFile Method | CreateTextFile Method | Delete Method | DeleteFolder Method | MoveFile Method
Applies To: FileSystemObject Object
Language
JScript

VBScript

Show All
Deletes a specified file.

object.DeleteFile ( filespec[, force] );

Arguments
object
Required. Always the name of a FileSystemObject.
filespec
Required. The name of the file to delete. The filespec can contain wildcard characters in the last path component.
force
Optional. Boolean value that is true if files with the read-only attribute set are to be deleted; false (default) if they are not.
Remarks
An error occurs if no matching files are found. The DeleteFile method stops on the first error it encounters. No attempt is made to roll back or undo any changes that were made before an error occurred.

The following example illustrates the use of the DeleteFile method.

[JScript]
function DeleteFile(filespec)
{
  var fso;
  fso = new ActiveXObject("Scripting.FileSystemObject");
  fso.DeleteFile(filespec);
}

[VBScript]
Sub DeleteAFile(filespec)
  Dim fso
  Set fso = CreateObject("Scripting.FileSystemObject")
  fso.DeleteFile(filespec)
End Sub

See Also
CopyFile Method | CreateTextFile Method | Delete Method | DeleteFolder Method | MoveFile Method
Applies To: FileSystemObject Object

--------------------------------------------------------------------------------

Send feedback on this topic to Microsoft.

© Microsoft Corporation. All rights reserved.


 
clickmaker ©   (2007-01-26 16:11) [4]


> [3] novill ©   (26.01.07 15:58)
> Сделал уже.
>
> Пока искал способы, нашел вот такую штуку

сильно подозреваю, что там внутрях
dwAttrib = GetFileAttributes(filespec);
if (force && ((dwAttrib & FILE_ATTRIBUTE_READONLY) == FILE_ATTRIBUTE_READONLY))
 SetFileAttribute(filespec, dwAttrib ^ FILE_ATTRIBUTE_READONLY);
DeleteFile(filespec);


 
Vlad Oshin ©   (2007-01-26 16:13) [5]

скорее всего..


 
novill ©   (2007-01-26 16:19) [6]

Так правильно снимать аттрибут?

var
sr:TSearchRec
...
if (sr.Attr and fareadonly)<>0 then SetFileAttributes(Pchar(sr.Name),sr.Attr xor faReadOnly);


 
Vlad Oshin ©   (2007-01-26 17:06) [7]

ну да,

только раз его все равно удалять, то чего проверять еще
сразу SetFileAttributes(Pchar(sr.Name), 0);


 
Vlad Oshin ©   (2007-01-26 17:10) [8]

object.DeleteFile ( filespec[, force] );
а если это опциональный параметр
то если его нет - просто делете, иначе даже без GetFileAttributes - сброс флага и делете


 
Плохиш ©   (2007-01-26 17:10) [9]

Только подставлять стоит полное имя файла, а то кто ж его знает, в какой папке его нашли и какая папка является текущей ;-)


 
novill ©   (2007-01-26 17:19) [10]

> [9] Плохиш ©   (26.01.07 17:10)

Это уже сделано.


 
MetalFan ©   (2007-01-26 17:40) [11]


> Пока искал способы, нашел вот такую штуку.
....
> Language
> JScript
>
> VBScript


ну это к нам, делфиноводам, не особо относится


 
novill ©   (2007-01-26 17:46) [12]

> [11] MetalFan ©   (26.01.07 17:40)

Если почитать MSDN то ни Дельфи, ни делфеводов быть не должно вообще :)


 
MetalFan ©   (2007-01-26 18:12) [13]


> novill ©   (26.01.07 17:46) [12]

примеденная цитата из MSDN не относится к PlatformSDK функции DeleteFile никак не относится.
вот что я имел ввиду)



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

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

Наверх




Память: 0.47 MB
Время: 0.049 c
4-1159303917
Dmitry_177
2006-09-27 00:51
2007.02.11
Борландовские сообщения CM_MOUSEENTER и CM_MOUSELEAVE в API


4-1159267238
tst
2006-09-26 14:40
2007.02.11
приклеить дополнительную форму


15-1169118389
Ксардас
2007-01-18 14:06
2007.02.11
подскажите плз сервер


2-1169640790
Light-blr
2007-01-24 15:13
2007.02.11
Можно ли из одного юнита взять константу другого?


15-1169512369
Lapushka-dochka
2007-01-23 03:32
2007.02.11
Подскажите, где взять документацию по компонентам PivotCube?





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
Английский Французский Немецкий Итальянский Португальский Русский Испанский