Hi,
Didn't You forget to remove the last "\" in "RmDir pstrDel_file"?
Try "RmDir left$(pstrDel_file, len(pstrDel_file)-1)"
Sorry for my English, I=B4m brazilian.
Juliano Moraes Rodrigues
Analista de Sistemas
FA Consult
S=E3o Paulo - Brasil
-----Mensagem original-----
De: Anthony Delcy [mailto:DELCYAN@l...]
Enviada em: sexta-feira, 27 de julho de 2001 10:32
Para: professional vb
Assunto: [pro_vb] RE: Problem with file
Hi,
I appreciate your response but it is not that.
After I delete a file I check in that same folder whether there are
other
files. If the folder contains no files it is only then that I try to
use
RmDIR on that folder. So, if it is empty, I take the same path minus
the
file and the extension and use RmDIR strPath.
The function I posted yesterday gets only the path and verify if the
path is
a directory or a file, then it will eight do a RmDIR to remove the
Directory
or Kill
to delete the file.
The function that verifies if the folder contains other files tells me
that
there is no more file, in the particular case that I am testing that
is, but
when I execute the RmDIR I got an error.
I even verify in the Win Explorer and indeed the folder is empty but
cannot
RmDIR it.
Thanks
Anthony Delcy
MIS
delcyan@m...
>>> Marco Straforini <marco.straforini@c...> 07/26 4:40 PM >>>
Anthony,
You cannot use RmDir to remove a folder if it still contains files.
Do remove a folder you have to recursively remove
all files and subfolders.
m.
> -----Original Message-----
> From: Anthony Delcy [SMTP:DELCYAN@l...]
> Sent: Thursday, July 26, 2001 11:26 AM
> To: professional vb
> Subject: [pro_vb] Problem with file
>
> Hi,
>
> In the following function I am trying to delete a directory and it
=3D
> generates this error: Path/File access error
>
> Details:
>
> My function gets a string value (a Path). I delete this path and then
loop
> =3D
> through the directory to see whether there are other files in this
=3D
> directory. If not, delete this folder.
> If I get a path which finishes with a "\" then I know it's a
directory, so
> =3D
> I remove this directory.
>
> Does anyone have an idea of what or how to overcome this problem.
> =3D20
>
> Private Sub SHDeleteFile(ByVal pstrDel_file As String)
> =3D20
> On Error GoTo ERR_SHDeleteFile
>
> If Dir(pstrDel_file, vbDirectory) <> "" Then
> If Right$(pstrDel_file, 1) <> "\" Then
> Kill pstrDel_file
> ''Update the ITG_File_Path that this File has been
deleted
> Call SQLDeleteFile(pstrDel_file)
> Else
> RmDir pstrDel_file
> End If
> End If
> Exit Sub
> =3D20
> ERR_SHDeleteFile:
> Err.Raise Err.Description
> =3D20
> End Sub
>
> Thank you
>
>
> Anthony Delcy
> MIS
> delcyan@m...