Hello, Good evening!

I am trying to validate my atachments in my system. In my program, there is an upload button, what I am trying to do is to validate it by not copying and saving the upload file once it already exists in the database.....

HERE IS MY CODE:

If System.I.O.Exists(FileToCopy)=True Then
    System.I.O.File.Copy(FileTo Copy, NewCopy)

Else
    MsgBox("File already exist")

but it is not working, any file uploaded eventhough it is not yet existing in the database is not saving...

.....Hope you could help me in this dilemma...

Recommended Answers

All 3 Replies

I think you want

If System.IO.File.Exists(FileToCopy) Then
    MsgBox("File already exists")
Else
    System.IO.File.Copy(FileToCopy, NewCopy)
End If

i tried that code as well but it does not save as well. tHE Message "File already exist" always show up whenever I upload may it be existing or not.......

My mistake. It was very early in the morning here. Try

If System.IO.File.Exists(NewCopy) Then
    MsgBox("File already exists")
Else
    System.IO.File.Copy(FileToCopy, NewCopy)
End If
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.