como crear una carpeta para luego guardar archivos.
Publicado por zendi (33 intervenciones) el 21/09/2018 18:15:43
he desarrollado este codigo para copiar archivos a una carpeta. El codigo funciona, pero la idea es crear la carpeta automaticamente y no de forma manual, he tenido que crear la carpeta de forma manual.
mi pregunta es: como hago para que se cree automaticamente?
en la primera linea en negrilla estoy tratando de crearla pero me da error.
mi pregunta es: como hago para que se cree automaticamente?
en la primera linea en negrilla estoy tratando de crearla pero me da error.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
MkDir C:/Users/equipo/Desktop/archivo
Const DestinationFile = "c:/Users/equipo/Desktop/archivo/copiar.vbs"
Const SourceFile = "c:/Users/equipo/Desktop/copiar.vbs"
Set fso = CreateObject("Scripting.FileSystemObject")
'Check to see if the file already exists in the destination folder
If fso.FileExists(DestinationFile) Then
'Check to see if the file is read-only
If Not fso.GetFile(DestinationFile).Attributes And 1 Then
'The file exists and is not read-only. Safe to replace the file.
fso.CopyFile SourceFile, "c:/Users/equipo/Desktop/archivo/copiar.vbs", True
Else
'The file exists and is read-only.
'Remove the read-only attribute
fso.GetFile(DestinationFile).Attributes = fso.GetFile(DestinationFile).Attributes - 1
'Replace the file
fso.CopyFile SourceFile, "c:/archivo/copiar.vbs", True
'Reapply the read-only attribute
fso.GetFile(DestinationFile).Attributes = fso.GetFile(DestinationFile).Attributes + 1
End If
Else
'The file does not exist in the destination folder. Safe to copy file to this folder.
fso.CopyFile SourceFile, "c:/Users/equipo/Desktop/archivo/copiar.vbs", True
End If
Valora esta pregunta


0