Copy excel file in vb.net/c# Options

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sukhsinghin
    New Member
    • Oct 2008
    • 2

    Copy excel file in vb.net/c# Options

    Hi,
    I am trying to make a copy of excel file using file.copy(path1 ,path2).
    its copying but making a blank file. Data is not getting copied.
    File.Copy(path, path2)

    Can anyone help me on this
    Thanks in advance.
  • kenobewan
    Recognized Expert Specialist
    • Dec 2006
    • 4871

    #2
    Are you using the office class?

    Comment

    • sukhsinghin
      New Member
      • Oct 2008
      • 2

      #3
      No. I am using System.IO.File class.

      Comment

      • kenobewan
        Recognized Expert Specialist
        • Dec 2006
        • 4871

        #4
        Just wondering whether the Microsoft Excel Object Library must be made available to your .NET project.

        If using Visual Studio .NET, a reference may be added to a project via the Project | Add Reference menu selection. The COM tab within the Add Reference window provides access to COM libraries installed on the system.

        Excel is listed as Microsoft.Excel , and the specific name will depend on the Excel version installed. If you have Excel 2003 on my system, so the COM library is listed as Microsoft.Excel 11.0 Object Library. In addition, two namespaces are necessary:

        Microsoft.Offic e.Interop.Excel : Allows you to work with Excel objects via .NET interop.
        System.Runtime. InteropServices : Includes the COMException class, allowing you to properly handle COM-related exceptions.

        Comment

        Working...