Windows replace file content

replace replace

Замена существующих файлов в каталоге. Replace existing files in a directory. При использовании с параметром /a эта команда добавляет новые файлы в каталог вместо того, чтобы заменять существующие файлы. If used with the /a option, this command adds new files to a directory instead of replacing existing files.

Синтаксис Syntax

Параметры Parameters

Параметр Parameter Описание Description
[ :][

] Указывает расположение и имя исходного файла или набора файлов. Specifies the location and name of the source file or set of files. Параметр filename является обязательным и может содержать символы-шаблоны (* и ?). The filename option is required, and can include wildcard characters (* and ?). [ :][

] Указывает расположение целевого файла. Specifies the location of the destination file. Нельзя указать имя файла для заменяемых файлов. You can’t specify a file name for files you replace. Если не указать диск или путь, эта команда использует текущий диск и каталог в качестве места назначения. If you don’t specify a drive or path, this command uses the current drive and directory as the destination. /a /a Добавляет новые файлы в каталог назначения вместо того, чтобы заменять существующие файлы. Adds new files to the destination directory instead of replacing existing files. Этот параметр командной строки нельзя использовать с параметром командной строки /s или /u . You can’t use this command-line option with the /s or /u command-line option. /p /p Запрашивает подтверждение перед заменой файла назначения или добавлением исходного файла. Prompts you for confirmation before replacing a destination file or adding a source file. /r /r Заменяет файлы, доступные только для чтения и незащищенные. Replaces Read-only and unprotected files. При попытке заменить файл, который доступен только для чтения, но не указан параметр /r, выдается сообщение об ошибке и останавливается операция замены. If you attempt to replace a Read-only file, but you don’t specify /r, an error results and stops the replacement operation. /W /w Ожидание вставки диска перед началом поиска исходных файлов. Waits for you to insert a disk before the search for source files begins. Если не указать /w, эта команда начнет заменять или добавлять файлы сразу после нажатия клавиши ВВОД. If you don’t specify /w, this command begins replacing or adding files immediately after you press ENTER. /s /s Выполняет поиск во всех подкаталогах в целевом каталоге и заменяет совпадающие файлы. Searches all subdirectories in the destination directory and replaces matching files. Параметр /s не может использоваться в командной строке /a . You can’t use /s with the /a command-line option. Команда не выполняет поиск в подкаталогах, указанных в path1. The command doesn’t search subdirectories that are specified in Path1. /U /u Заменяет только те файлы в конечном каталоге, которые старше, чем в исходном каталоге. Replaces only those files on the destination directory that are older than those in the source directory. Нельзя использовать /u с параметром командной строки /a . You can’t use /u with the /a command-line option. /? /? Отображение справки в командной строке. Displays help at the command prompt.

Комментарии Remarks

Так как эта команда добавляет или заменяет файлы, имена файлов отображаются на экране. As this command adds or replaces files, the file names appear on the screen. По завершении этой команды отображается строка сводки в одном из следующих форматов: After this command is done, a summary line is displayed in one of the following formats:

Если вы используете гибкие диски и вам необходимо переключить диски при выполнении этой команды, можно указать параметр командной строки /w , чтобы эта команда ожидает переключения дисков. If you’re using floppy disks and you need to switch disks while running this command, you can specify the /w command-line option so that this command waits for you to switch the disks.

Эту команду нельзя использовать для обновления скрытых файлов или системных файлов. You can’t use this command to update hidden files or system files.

В следующей таблице показан каждый код выхода и краткое описание его значения. The following table shows each exit code and a brief description of its meaning:

Код выхода Exit code Описание Description
0 0 Эта команда успешно заменила или добавила файлы. This command successfully replaced or added the files.
1 1 Эта команда обнаружила неправильную версию MS-DOS. This command encountered an incorrect version of MS-DOS.
2 2 Этой команде не удалось найти исходные файлы. This command couldn’t find the source files.
3 3 Этой команде не удалось найти исходный или конечный путь. This command couldn’t find the source or destination path.
5 5 У пользователя нет доступа к файлам, которые требуется заменить. The user doesn’t have access to the files that you want to replace.
8 8 Недостаточно системной памяти для выполнения команды. There is insufficient system memory to carry out the command.
11 11 Пользователь использовал неправильный синтаксис в командной строке. The user used the wrong syntax on the command line.

Можно использовать параметр ERRORLEVEL в командной строке If в пакетной программе для обработки кодов завершения, возвращаемых этой командой. You can use the ERRORLEVEL parameter on the if command line in a batch program to process exit codes that are returned by this command.

File. Replace Метод

Определение

Заменяет содержимое заданного файла на содержимое другого файла, удаляя исходный файл и создавая резервную копию замененного файла. Replaces the contents of a specified file with the contents of another file, deleting the original file, and creating a backup of the replaced file.

Перегрузки

Заменяет содержимое заданного файла на содержимое другого файла, удаляя исходный файл и создавая резервную копию замененного файла. Replaces the contents of a specified file with the contents of another file, deleting the original file, and creating a backup of the replaced file.

Заменяет содержимое заданного файла на содержимое другого файла, удаляя исходный файл и создавая резервную копию замененного файла, и при необходимости игнорирует ошибки слияния. Replaces the contents of a specified file with the contents of another file, deleting the original file, and creating a backup of the replaced file and optionally ignores merge errors.

Комментарии

ReplaceМетоды заменяют содержимое указанного файла содержимым другого файла. The Replace methods replace the contents of a specified file with the contents of another file. Они также создают резервную копию файла, который был заменен. They also create a backup of the file that was replaced.

Replace(String, String, String)

Заменяет содержимое заданного файла на содержимое другого файла, удаляя исходный файл и создавая резервную копию замененного файла. Replaces the contents of a specified file with the contents of another file, deleting the original file, and creating a backup of the replaced file.

Параметры

Имя файла, который заменяет файл, указанный destinationFileName . The name of a file that replaces the file specified by destinationFileName .

Имя заменяемого файла. The name of the file being replaced.

Имя файла резервной копии. The name of the backup file.

Исключения

Путь, описываемый параметром destinationFileName , имел недопустимую форму. The path described by the destinationFileName parameter was not of a legal form.

-или- -or- Путь, описываемый параметром destinationBackupFileName , имел недопустимую форму. The path described by the destinationBackupFileName parameter was not of a legal form.

Параметр destinationFileName имеет значение null . The destinationFileName parameter is null .

Указан недопустимый диск. An invalid drive was specified.

Не удалось найти файл, описанный текущим объектом FileInfo. The file described by the current FileInfo object could not be found.

-или- -or- Файл, описываемый параметром destinationBackupFileName , не найден. The file described by the destinationBackupFileName parameter could not be found.

При открытии файла произошла ошибка ввода-вывода. An I/O error occurred while opening the file.

-или- -or- Параметры sourceFileName и destinationFileName указывают один и тот же файл. The sourceFileName and destinationFileName parameters specify the same file.

Указанный путь, имя файла или оба значения превышают максимальную длину, заданную в системе. The specified path, file name, or both exceed the system-defined maximum length.

Параметр sourceFileName или destinationFileName указывает файл, доступный только для чтения. The sourceFileName or destinationFileName parameter specifies a file that is read-only.

-или- -or- Эта операция не поддерживается на текущей платформе. This operation is not supported on the current platform.

-или- -or- Исходные или конечные параметры определяют каталог вместо файла. Source or destination parameters specify a directory instead of a file.

-или- -or- У вызывающего объекта отсутствует необходимое разрешение. The caller does not have the required permission.

Примеры

В следующем примере кода метод используется Replace для замены файла другим файлом и создания резервной копии замененного файла. The following code example uses the Replace method to replace a file with another file and create a backup of the replaced file.

Комментарии

ReplaceМетод заменяет содержимое указанного файла содержимым другого файла. The Replace method replaces the contents of a specified file with the contents of another file. Он также создает резервную копию файла, который был заменен. It also creates a backup of the file that was replaced.

Если sourceFileName и destinationFileName находятся на разных томах, этот метод вызовет исключение. If the sourceFileName and destinationFileName are on different volumes, this method will raise an exception. Если объект destinationBackupFileName находится на другом томе из исходного файла, то файл резервной копии будет удален. If the destinationBackupFileName is on a different volume from the source file, the backup file will be deleted.

Передайте null destinationBackupFileName параметр, если не хотите создавать резервную копию заменяемого файла. Pass null to the destinationBackupFileName parameter if you do not want to create a backup of the file being replaced.

Если объект destinationBackupFileName уже существует, он будет перезаписан с содержимым destinationFileName файла. If the destinationBackupFileName already exists it will be overwritten with the contents of the destinationFileName file.

Применяется к

Replace(String, String, String, Boolean)

Заменяет содержимое заданного файла на содержимое другого файла, удаляя исходный файл и создавая резервную копию замененного файла, и при необходимости игнорирует ошибки слияния. Replaces the contents of a specified file with the contents of another file, deleting the original file, and creating a backup of the replaced file and optionally ignores merge errors.

Параметры

Имя файла, который заменяет файл, указанный destinationFileName . The name of a file that replaces the file specified by destinationFileName .

Имя заменяемого файла. The name of the file being replaced.

Имя файла резервной копии. The name of the backup file.

Значение true позволяет игнорировать ошибки слияния (например, атрибуты и списки управления доступом (ACL)), исходящие из заменяемого файла в заменяющий; в противном случае — значение false . true to ignore merge errors (such as attributes and access control lists (ACLs)) from the replaced file to the replacement file; otherwise, false .

Исключения

Путь, описываемый параметром destinationFileName , имел недопустимую форму. The path described by the destinationFileName parameter was not of a legal form.

-или- -or- Путь, описываемый параметром destinationBackupFileName , имел недопустимую форму. The path described by the destinationBackupFileName parameter was not of a legal form.

Параметр destinationFileName имеет значение null . The destinationFileName parameter is null .

Указан недопустимый диск. An invalid drive was specified.

Не удалось найти файл, описанный текущим объектом FileInfo. The file described by the current FileInfo object could not be found.

-или- -or- Файл, описываемый параметром destinationBackupFileName , не найден. The file described by the destinationBackupFileName parameter could not be found.

При открытии файла произошла ошибка ввода-вывода. An I/O error occurred while opening the file.

-или- -or- Параметры sourceFileName и destinationFileName указывают один и тот же файл. The sourceFileName and destinationFileName parameters specify the same file.

Указанный путь, имя файла или оба значения превышают максимальную длину, заданную в системе. The specified path, file name, or both exceed the system-defined maximum length.

Параметр sourceFileName или destinationFileName указывает файл, доступный только для чтения. The sourceFileName or destinationFileName parameter specifies a file that is read-only.

-или- -or- Эта операция не поддерживается на текущей платформе. This operation is not supported on the current platform.

-или- -or- Исходные или конечные параметры определяют каталог вместо файла. Source or destination parameters specify a directory instead of a file.

-или- -or- У вызывающего объекта отсутствует необходимое разрешение. The caller does not have the required permission.

Примеры

В следующем примере кода метод используется Replace для замены файла другим файлом и создания резервной копии замененного файла. The following code example uses the Replace method to replace a file with another file and create a backup of the replaced file.

Комментарии

ReplaceМетод заменяет содержимое указанного файла содержимым другого файла. The Replace method replaces the contents of a specified file with the contents of another file. Он также создает резервную копию файла, который был заменен. It also creates a backup of the file that was replaced.

Если sourceFileName и destinationFileName находятся на разных томах, этот метод вызовет исключение. If the sourceFileName and destinationFileName are on different volumes, this method will raise an exception. Если объект destinationBackupFileName находится на другом томе из исходного файла, то файл резервной копии будет удален. If the destinationBackupFileName is on a different volume from the source file, the backup file will be deleted.

Передайте null destinationBackupFileName параметр, если не хотите создавать резервную копию заменяемого файла. Pass null to the destinationBackupFileName parameter if you do not want to create a backup of the file being replaced.

Если объект destinationBackupFileName уже существует, он будет перезаписан с содержимым destinationFileName файла. If the destinationBackupFileName already exists it will be overwritten with the contents of the destinationFileName file.

Читайте также:  Windows phone ip камер
Оцените статью