Victor Charles
asked on
Help with over writing xml file
Hi,
How do I modify the code below to receive a message a file already exist and over write it?
FolderBrowserDialog1.Selec tedPath = Application.StartupPath & "\LinkFiles"
Dim dlgResult As DialogResult
dlgResult = FolderBrowserDialog1.ShowD ialog()
If dlgResult = DialogResult.OK Then
System.IO.File.Copy(Applic ation.Star tupPath & "\LinkFiles\LinkFinal" & Trim(LoginForm1.username.T ext) & ".xml", _
FolderBrowserDialog1.Selec tedPath & "\LinkFinal" & Trim(LoginForm1.username.T ext) & ".xml")
End If
Thanks,
Victor
How do I modify the code below to receive a message a file already exist and over write it?
FolderBrowserDialog1.Selec
Dim dlgResult As DialogResult
dlgResult = FolderBrowserDialog1.ShowD
If dlgResult = DialogResult.OK Then
System.IO.File.Copy(Applic
FolderBrowserDialog1.Selec
End If
Thanks,
Victor
ASKER
Hi,
When I try the code below and the file already exist in the folder I want to save it, I receive error message " File already exist" How do I fix this error?
FolderBrowserDialog1.Selec tedPath = Application.StartupPath & "\LinkFiles"
Dim dlgResult As DialogResult
dlgResult = FolderBrowserDialog1.ShowD ialog()
If dlgResult = DialogResult.OK Then
System.IO.File.Copy(Applic ation.Star tupPath & "\LinkFiles\LinkFinal" & Trim(LoginForm1.username.T ext) & ".xml", _
FolderBrowserDialog1.Selec tedPath & "\LinkFinal" & Trim(LoginForm1.username.T ext) & ".xml")
End If
Thanks,
Victor
When I try the code below and the file already exist in the folder I want to save it, I receive error message " File already exist" How do I fix this error?
FolderBrowserDialog1.Selec
Dim dlgResult As DialogResult
dlgResult = FolderBrowserDialog1.ShowD
If dlgResult = DialogResult.OK Then
System.IO.File.Copy(Applic
FolderBrowserDialog1.Selec
End If
Thanks,
Victor
Add a ", True" as a third parameter to the File.Copy method. My apologies for failing to put that in the code when I posted it in the prior question.
ASKER
Hi,
It worked. How do I notify the users if the file already exist and give them a choice to overwrite or cancel?
Tnaks,
Victor
It worked. How do I notify the users if the file already exist and give them a choice to overwrite or cancel?
Tnaks,
Victor
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank You.
Dim dlgResult As DialogResult
dlgResult = FolderBrowserDialog1.ShowD
If dlgResult = DialogResult.OK Then
System.IO.File.Copy(Applic
FolderBrowserDialog1.Selec
' something like this
If My.Computer.FileSystem.Fil
) Then
MsgBox(' file exists do you wnat to overwrite yes/no message here dialog)
if dialog = yes
then
File.Copy('Source here, Path.Combine(sFolder,Folde
Else
' do nothing
End IF
END IF