Foros del Web » Programando para Internet » ASP Clásico »

problema con CopyFile y ficheros solo lectura

Estas en el tema de problema con CopyFile y ficheros solo lectura en el foro de ASP Clásico en Foros del Web. tengo un problema, y es que no puedo hacer un copyfile sobreescribiendo el archivo existente porque el archivo que cojo para copiar tiene atributos de ...
  #1 (permalink)  
Antiguo 21/02/2002, 12:10
Avatar de Ruchu  
Fecha de Ingreso: octubre-2001
Mensajes: 698
Antigüedad: 22 años, 8 meses
Puntos: 2
problema con CopyFile y ficheros solo lectura

tengo un problema, y es que no puedo hacer un copyfile sobreescribiendo el archivo existente porque el archivo que cojo para copiar tiene atributos de solo lectura y entonces tambien lo copio con atributo solo lectura, y no puedo cambiarlo, porque se trataria de cambiar 4.000 ficheros(no se si puedo hacer un bucle que vaya recorriendo todos los ficheros y cambviando el atributo, no se)

el codigo que uso es este, el normal.

Set FS = Server.CreateObject("Scripting.FileSystemObje ct")
FS.CopyFile Server.Mappath("../ilustraciones/"&miTabla(0, no)&".jpg"), Server.Mappath("img"&conta&&quot ;.jpg"),True
Set FS=Nothing


ayuda¿?¿?
  #2 (permalink)  
Antiguo 21/02/2002, 12:24
Avatar de Ruchu  
Fecha de Ingreso: octubre-2001
Mensajes: 698
Antigüedad: 22 años, 8 meses
Puntos: 2
Re: problema con CopyFile y ficheros solo lectura

y que por cierto, que no lo dije, el error que me da:

Permiso denegado.
  #3 (permalink)  
Antiguo 22/02/2002, 04:07
Avatar de Ruchu  
Fecha de Ingreso: octubre-2001
Mensajes: 698
Antigüedad: 22 años, 8 meses
Puntos: 2
Re: problema con CopyFile y ficheros solo lectura

nadie lo sabe???

buaaaaaaaaaaaaa :(
  #4 (permalink)  
Antiguo 22/02/2002, 04:34
 
Fecha de Ingreso: febrero-2002
Ubicación: Alicante España
Mensajes: 30
Antigüedad: 22 años, 4 meses
Puntos: 0
Re: problema con CopyFile y ficheros solo lectura

Hola

He encontrado esto en: http://msdn.microsoft.com/library/default.asp?url=/nhp/Default.asp?contentid=28001169&amp

'''''''''''''''''''''''''''''''''''''''''''''
' ShowFileAttr
' Purpose:
' Generates a string describing the attributes of a file or folder.
' Demonstrates the following
' - File.Attributes
' - Folder.Attributes
'''''''''''''''''''''''''''''''''''''''''''''

Function ShowFileAttr(File) ' File can be a file or folder

Dim S
Dim Attr

Attr = File.Attributes

If Attr = 0 Then
ShowFileAttr = "Normal"
Exit Function
End If

If Attr And FileAttrDirectory Then S = S & "Directory "
If Attr And FileAttrReadOnly Then S = S & "Read-Only "
If Attr And FileAttrHidden Then S = S & "Hidden "
If Attr And FileAttrSystem Then S = S & "System "
If Attr And FileAttrVolume Then S = S & "Volume "
If Attr And FileAttrArchive Then S = S & "Archive "
If Attr And FileAttrAlias Then S = S & "Alias "
If Attr And FileAttrCompressed Then S = S & "Compressed "

ShowFileAttr = S

End Function

Espero te sirva de algo.
Saludos
  #5 (permalink)  
Antiguo 22/02/2002, 04:48
Avatar de Ruchu  
Fecha de Ingreso: octubre-2001
Mensajes: 698
Antigüedad: 22 años, 8 meses
Puntos: 2
Re: problema con CopyFile y ficheros solo lectura

hola GenX. esa funcion esta buena, sip. pero no me sirve de nada porque por lo que veo lo unico que hace es mostrar los atributos del fichero, no los cambia.

aunque voy a prbarla igualmente, pero no me servira, seguro. :(
  #6 (permalink)  
Antiguo 22/02/2002, 04:57
 
Fecha de Ingreso: febrero-2002
Ubicación: Alicante España
Mensajes: 30
Antigüedad: 22 años, 4 meses
Puntos: 0
Re: problema con CopyFile y ficheros solo lectura

Hola Ruchu

Lo interesante esta en http://msdn.microsoft.com/downloads/default.asp?url=/downloads/sample.asp?url=/msdn-files/027/001/728/msdncompositedoc.xml&frame=true

es una documentación de scrip que contiene documentación de FileSystemObject que esta muy combleta, lo malo es que no tengo tiempo de leerla, pero alli tal vez puedas encontrar algo de lo que necesitas.

Saludos
  #7 (permalink)  
Antiguo 22/02/2002, 05:08
 
Fecha de Ingreso: febrero-2002
Ubicación: Alicante España
Mensajes: 30
Antigüedad: 22 años, 4 meses
Puntos: 0
Re: problema con CopyFile y ficheros solo lectura

Hola Ruchu

Te tengo otro codigo:

Arguments
object
Required. Always the name of a File or Folder object.
newattributes
Optional. If provided, newattributes is the new value for the attributes of the specified object.
Settings
The newattributes argument can have any of the following values or any logical combination of the following values:

Constant Value Description
Normal 0 Normal file. No attributes are set.
ReadOnly 1 Read-only file. Attribute is read/write.
Hidden 2 Hidden file. Attribute is read/write.
System 4 System file. Attribute is read/write.
Volume 8 Disk drive volume label. Attribute is read-only.
Directory 16 Folder or directory. Attribute is read-only.
Archive 32 File has changed since last backup. Attribute is read/write.
Alias 64 Link or shortcut. Attribute is read-only.
Compressed 128 Compressed file. Attribute is read-only.

Remarks
The following code illustrates the use of the Attributes property with a file:

[JScript]
function ToggleArchiveBit(filespec)
{
var fso, f, r, s;
fso = new ActiveXObject("Scripting.FileSystemObject&quo t;);
f = fso.GetFile(filespec)
if (f.attributes && 32)
{
f.attributes = f.attributes - 32;
s = "Archive bit is cleared.";
}
else
{
f.attributes = f.attributes + 32;
s = "Archive bit is set.";
}
return(s);
}
[VBScript]
Function ToggleArchiveBit(filespec)
Dim fso, f
Set fso = CreateObject("Scripting.FileSystemObject&quot ;)
Set f = fso.GetFile(filespec)
If f.attributes and 32 Then
f.attributes = f.attributes - 32
ToggleArchiveBit = "Archive bit is cleared."
Else
f.attributes = f.attributes + 32
ToggleArchiveBit = "Archive bit is set."
End If
End Function
  #8 (permalink)  
Antiguo 22/02/2002, 05:31
Avatar de Ruchu  
Fecha de Ingreso: octubre-2001
Mensajes: 698
Antigüedad: 22 años, 8 meses
Puntos: 2
Re: problema con CopyFile y ficheros solo lectura

oks GenX, me voy para microsoft a furulear a ver que encuentro. :)
  #9 (permalink)  
Antiguo 25/03/2002, 17:15
Avatar de venom_plus  
Fecha de Ingreso: marzo-2002
Ubicación: Nogales, Sonora
Mensajes: 61
Antigüedad: 22 años, 2 meses
Puntos: 0
Re: problema con CopyFile y ficheros solo lectura

Hola Ruchu:
Me preguntaba si has resuelto ya tu problema, porque a mi me ocurre exactamente lo mismo. Ojala me puedas ayudar.
  #10 (permalink)  
Antiguo 25/03/2002, 18:14
 
Fecha de Ingreso: octubre-2000
Ubicación: Juarez, Chih.
Mensajes: 161
Antigüedad: 23 años, 8 meses
Puntos: 0
Re: problema con CopyFile y ficheros solo lectura

Saludos.

Ruchu: El siguiente código te servirá para editar el atributo readonly de x archivos.

Tan solo edita una línea para especificar donde quieres que inicie la edicion y esta se hara recursivamente sobre los directorios hijos.

<%
Option Explicit
Response.Buffer = True
Dim Path
Path = server.mappath("./") 'ejemplo usando el directorio actual
Call Editar(Path) 'empieza la busqueda y edición
Session("counter") = 0
%>

<%
Function Editar(PathSpec)
Dim Fso, FolderInfo, Filelist, Archivo, File
Set Fso = CreateObject("Scripting.FileSystemObject&quot ;)
Set FolderInfo = Fso.GetFolder(PathSpec)
Set FileList = FolderInfo.Files

For Each File in FileList
Archivo = FormatURL(PathSpec) & "/" & UCase(Cstr(File.Name))
Session("Counter") = Session("Counter") + 1
Response.Write Session("Counter") & ".- " & Archivo & " " & Quitar_solo_lectura(Archivo) & "<br>"
Next
Dim f, fc, folder
Set f = Fso.GetFolder(PathSpec)
Set fc = f.SubFolders
For Each Folder in fc
Call Editar(PathSpec & "\" & Folder.Name)
Next
End Function
%>

<%
Function Quitar_solo_lectura(strFileName)
Dim objFSO, objFile
Set objFSO = Server.CreateObject("Scripting.FileSystemObje ct")
Set objFile = objFSO.GetFile(Server.MapPath(strFileName))
If objFile.Attributes AND 1 then
objFile.Attributes = objFile.Attributes - 1
Quitar_solo_lectura = " <b>Atributo editado.</b>"
End If
End Function
%>

<%
Function FormatURL(strPath)
Dim iPos
Dim str
iPos = InStr(1,strPath,"wwwroot",1)
str = Mid(strPath,iPos+7,Len(strPath))
FormatURL = Replace(str,"\","/")
End Function
%>



---------------------
Tan libre como gratuito!!!
  #11 (permalink)  
Antiguo 26/03/2002, 04:01
Avatar de Ruchu  
Fecha de Ingreso: octubre-2001
Mensajes: 698
Antigüedad: 22 años, 8 meses
Puntos: 2
Re: problema con CopyFile y ficheros solo lectura

pues si, ya solucione el problema y sin nada de codigo. :)

la solucion es bastante simple, eso si, si los ficheros estan en tu hd, no en el server.

mira, imaina que tienes los ficheros en la carpeta c:\inetpub\misficheros\

pues haces click con el botón derecho sobre la carpeta, seleccionas Propiedades, y le quitas el atributo solo lectura. despues te pregunta si quieres cambiar el atributo a todos los ficheros que hey dentro de la carpeta, le dices que si y listo. problema solucionado.

esto va muy bien si como digo los ficheros los tienes en tu disco duro, si estos estan en el server, puedes hacer dos cosas:

1. te los bajas y haces lo que he comentado anteriormente con lo del click derecho.

2. o utilizas un codigo como el que escribio nuestro amigo vgaray.

Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 00:16.