tags:

views:

670

answers:

4

What is the command to create a copy of a excel file without opening it using vb.net.

Can anyone helpe me out there....

Thank you.

+3  A: 

File.Copy

http://msdn.microsoft.com/en-us/library/system.io.file.copy(VS.71).aspx

Chris Ballance
A: 

that would probably do it?

Fredou
Now I can create a copy of excel file using File.copy command in vb.net but how to copy if the total character of folder structure including file name exceed 260 char. It throws exception. Please help me.
Suman
+2  A: 

Let's keep it VB-centric: My.Computer.FileSystem.CopyFile().

Hans Passant
A: 

The parm 'true' in the copy method says to overwrite any existing file so it doesn't bomb out.

Imports System.IO
Module Module1
    Sub Main()
        Dim originalFile As String = "c:\work\myExcelFile.xls"
        Dim copyOfOriginalFile As String = "c:\work\myExcelFileCopy.xls"

        If File.Exists(originalFile) Then
            System.IO.File.Copy(originalFile, copyOfOriginalFile, True) 
        Else
            Console.WriteLine("{0} does not exist", originalFile)
        End If
    End Sub
End Module
Gern Blandston