hi,
I am desiging ASP.net website , in one of the forms I need to import data to an excel work book with a specific name but I need to check first is that work bokk already exist so not recreate but only add a sheet to it . here is segment of the code to chekc:
If FileExists(path & doc_ID) Then
MsgBox("already exists ", MsgBoxStyle.MsgBoxSetForeground)
Else
'Start a new workbook in Excel.
oExcel = CreateObject("Excel.Application")
oBook = oExcel.Workbooks.Add
calculation()
oBook.SaveAs(path & doc_ID)
'oSheet = Nothing
oBook = Nothing
oExcel.Quit()
oExcel = Nothing
GC.Collect()
MsgBox("Done")
Response.Redirect("calculateResults.aspx")
End If
the method FileExists is as follows :
Private Function FileExists(ByVal FileFullPath As String) _
As Boolean
'If Trim(FileFullPath) = "" Then Return False
Dim f As New IO.FileInfo(FileFullPath)
Return f.Exists()
End Function
note the does not contain the operation of adding a sheet but only display msg,
The problem is even if a have a file with the same exact name it never shows the msg box
any body can help, I'll appreciate it