Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Accessing Folder on Remote Sever Using FileSystemObject

Status
Not open for further replies.

idbr

MIS
May 1, 2003
247
GB
Hi,

I'm having a bit of a problem with the above. I need to access a remote server, pick up an image and dump it back onto my local server. However, the folder on the remote server has a space in the filename which seems to stop the pathe being recognised! Any ideas for a workaround/fix? Here's the code that doesn't work:

Code:
'============================
'Move the files to our server
'============================

dim fs as FileSystemObject
dim fl as File

dim rst as DAO.Recordset

dim strPRPData  as String
dim strSaveFolder as String

strSaveFolder = "P:\Shared\insolvency\ForwardFlow\TestTiffs\"

strPRPData = "SELECT Case.CaseID, tblDWFExtractData.ProposalFileName, Case.PNumber " & _
"FROM [Case] INNER JOIN tblDWFExtractData ON Case.PNumber = tblDWFExtractData.PNumber; "

Set rst = dbs.OpenRecordset(strPRPData, dbOpenDynaset, dbSeeChanges)

rst.MoveFirst

Set fs = New FileSystemObject

Do Until rst.EOF

strFileToCopy = "\\lds-1101\Document Output\" & rst("CaseID") & "\" & Right(rst("ProposalFileName"), Len(rst("ProposalFileName")) - 2)

'***Breaks here with 'file not found' error***
Set fl = fs.GetFile(strFileToCopy)

'   Set fl = fs.GetFile(strFileToCopy)
    fl.Copy (strSaveFolder)

    rst.MoveNext

Loop

'etc...

Replacing strFileToCopy with "\\lds-1101\Data\Test.tif" works, hence I think it's the space causing the problem.

Thanks, Iain
 
add an extra double quote to the start and end of the FULL filename.
e.g.
strFileToCopy = """\\lds-1101\Data\Test with space .tif"""

This may work. haven't tried it.

Regards

Frederico Fonseca
SysSoft Integrated Ltd
 
Hi Frederico, apologies for the delayed response - have been out of the office for a week.

Unforunately providing either double or single quotes to the string doesn't work. Strangely enough though, the Name function does, so I'm working around with:

Code:
Dim strOldFileName as string
dim strNewFileName as string

strOldFileName = strSaveFolder & rst("PNumber") & ".tif"
strNewFileName = strSaveFolder & rst("PNumber") & "1.tif"

'move the file off LDS-1101
[COLOR=blue]Name[/color blue] strFileToCopy [COLOR=blue]As[/color blue] strOldFileName

'Make a copy of this file
Set fl = fs.GetFile(strOldFileName)
fl.Copy (strNewFileName)

'Move the copy back to LDS-1101, changing the name back to the original
[COLOR=blue]Name[/color blue] strNewFileName [COLOR=blue]As[/color blue] strFileToCopy

I'm doing this because I need to leave the original file on the other server. However, I'd rather not run the risk of moving the file off the other server and back again. Any other suggestions?

Thanks, Iain
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top