🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: free.it.visual-basic
Article #3041

Problema di copia file

#3041
From: SelectroM
Date: Wed, 30 Oct 2002 17:27
39 lines
2147 bytes
Sto cercando di scrivere un programma che esegua una copia di un file con
una diversa estensione a mo' di backup; pensavo fosse una banalit�.

Ho provato alcuni metodi, ma non sono riuscito a risolvere il problema che
se nel percorso c'� uno spazio, il programma abortisce con Run-time error
52 - Bad file name or number. Se, invece, non vi sono spazi, la copia
procede regolarmente.

In MSDE non ho trovato nulla di illuminante.
In calce il sorgente ridotto all'osso.

Grazie per l'eventuale aiuto.
Marco Springhetti

*******************************************

Private Sub Form_Load()
    Dim Fname, FnameRoot, NewFname, NewExt As String
    Dim OldX, PosDot As Integer
    Dim fso As New FileSystemObject
'
    Fname = CStr(Command)
'   Se imposto a mano Fname = "c:\aaa aaa\a a.txt" funziona bene!!!
    If Len(Fname) = 0 Then
        GoTo out
    End If
    PosDot = InStrRev(Fname, ".")
    FnameRoot = Left(Fname, PosDot)
    OldX = 0
A1: OldX = OldX + 1
    NewExt = "old" & CStr(OldX)
    NewFname = FnameRoot & NewExt
    If fso.FileExists(NewFname) Then
        GoTo A1
    End If
    fso.CopyFile Fname, NewFname
out:
    Unload Me
End Sub
Technical Details
Message-ID: <GDUv9.52312$aL4.1586536@news1.tin.it>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-03!sn-xit-06!sn-xit-04!supernews.com!news.maxwell.syr.edu!nntp.infostrada.it!news-out.tin.it!news-in.tin.it!news1.tin.it.POSTED!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ITALIAN,ASCII
X-Google-Thread: f94ee,307373c50f941c2e,start
X-Google-Attributes: gidf94ee,public
X-Google-ArrivalTime: 2002-10-30 09:32:03 PST
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-03!sn-xit-06!sn-xit-04!supernews.com!news.maxwell.syr.edu!nntp.infostrada.it!news-out.tin.it!news-in.tin.it!news1.tin.it.POSTED!not-for-mail
From: "SelectroM" <msprin.no_spam_thanks@tin.it>
Newsgroups: free.it.visual-basic
Subject: Problema di copia file
Lines: 43
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1106
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106
Message-ID: <GDUv9.52312$aL4.1586536@news1.tin.it>
Date: Wed, 30 Oct 2002 17:27:02 GMT
NNTP-Posting-Host: 62.211.159.7
X-Complaints-To: newsmaster@tin.it
X-Trace: news1.tin.it 1035998822 62.211.159.7 (Wed, 30 Oct 2002 18:27:02 MET)
NNTP-Posting-Date: Wed, 30 Oct 2002 18:27:02 MET
Organization: TIN