afgone
SSCommitted
Points: 1551
More actions
April 24, 2008 at 4:10 am
#184777
hi,
I am moving a file in script task using the following code
For Each f As String In Directory.GetFiles(DirToCreate) If f IsNot Nothing Then Dim i As String = f.Substring(97, CInt(IIf(Convert.ToInt32(f.LastIndexOf("/")) < 0, _ 14, Convert.ToInt32(f.LastIndexOf("/"))))).Replace("/", "\") File.Move(f, "C:\TEST\" + i) End If Next
For Each f As String In Directory.GetFiles(DirToCreate)
If f IsNot Nothing Then
Dim i As String = f.Substring(97, CInt(IIf(Convert.ToInt32(f.LastIndexOf("/")) < 0, _
14, Convert.ToInt32(f.LastIndexOf("/"))))).Replace("/", "\")
File.Move(f, "C:\TEST\" + i)
End If
Next
the problem is if the file already exists then it will say Cannot create a file when that file already exists. now is it possible to overwrite the existing file, if so can you help me how to do it?
thanks
Andrew Watson-478275
SSCarpal Tunnel
Points: 4652
April 25, 2008 at 9:59 am
#807282
I have to admit I'm writing this without checking, but it's probably something like this:
If FileExists("C:\Test\" + i)
DeleteFile("C:\Test\" + i)
File.Move(f,"C:\Test\" + i)
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply