Results 1 to 2 of 2

Thread: Interrupt Function?

  1. #1

    Thread Starter
    Lively Member carl_mathews200's Avatar
    Join Date
    May 2004
    Location
    Wales, UK
    Posts
    94

    Arrow Interrupt Function?

    Hi,

    I am passing a collection of filenames to my business layer, which then copies the files from the paths specified in the collection to another location while creating entries in the database.

    If the file already exists at the new location, is there any way to Interrupt the function and ask the user if they want to replace the existing file and then continue the operation?

    Any help will be great

  2. #2
    Frenzied Member Ideas Man's Avatar
    Join Date
    Aug 2002
    Location
    Australia
    Posts
    1,718
    You could do that by using the FileInfo class.

    In your function, create a variable like the following:
    VB Code:
    1. Dim fInfo as New FileInfo([i]FileName[/i])

    Then to see if the file exists, do the following:
    VB Code:
    1. If fInfo.Exists = True Then
    2.     If MessageBox.Show("File exists. Would you like to replace?", "Prompt", MessageBoxButtons.YesNo) = DialogResult.Yes Then
    3.         'Code to replace
    4.     End If
    5. End If
    I use Microsoft Visual Basic 2005. (Therefore, most code samples I provide will be based around the .NET Framework v2.0, unless otherwise specified)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width