473,406 Members | 2,371 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

File copy VB Exp 2005

I thought I was creating a simple little app, but it's kicking my butt right
now. I've searched the help and can't find enough to get me where I need to
be.

I'm creating a CD to distribute to my field personnel. The purpose of the
app is to copy some files from the CD to an obscure destination directory on
the machine. The destination directory can change on the target machine and
is identified as IcmPath. (IcmPath is populated elsewhere in the code).

The first problem is with the source. I have to explicitly name the files I
want to copy, but I would prefer to not so I don't have to recompile the app
everytime the source files change and a new CD is built.

So, as in my example below, when I specify the files to copy and run this,
it tells me that my destination directory already exists. But it will
always exist, it is put in place by the original software installation and
contains sub directories.

I guess I'm kind of confused about how to do this. Any help would be
appreciated!

Thanks,

Darhl

Private Sub cmdYes_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles cmdYes.Click

Source = "\files\pos.ico"

Dest = IcmPath & "\ICM\Package"

My.Computer.FileSystem.CopyFile(Source, Dest)

MsgBox("Files copied into " & IcmPath & "\ICM\Package")

End Sub
May 8 '06 #1
6 4255
> So, as in my example below, when I specify the files to copy and run
this, it tells me that my destination directory already exists. But
it will always exist, it is put in place by the original software
installation and contains sub directories.
Private Sub cmdYes_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles cmdYes.Click

Source = "\files\pos.ico"

Dest = IcmPath & "\ICM\Package"

My.Computer.FileSystem.CopyFile(Source, Dest)

MsgBox("Files copied into " & IcmPath & "\ICM\Package")

End Sub
It appears that you are trying to copy the file to the directory, not into
it. Try to tack on the \pos.ico to the end of your Dest string as follows:
Dest = IcmPath & "\ICM\Package\pos.ico"


Additionally, you may want to take the overload on the CopyFile method that
forces an overwrite:
My.Computer.FileSystem.CopyFile(Source, Dest, True)

Jim Wooley
http://devauthority.com/blogs/jwooley/default.aspx
May 8 '06 #2
Hi Jim,

That did work, but I really don't want to have to specify the files. I'm
just using pos.ico as a test bed, but in reality, there may be up to 10
files in the \files directory on the CD that need to be copied into the
IcmPath\ICM\Package folder. I want the app to find the names on it's own,
not specify them. Is this possible? I've tried putting *.* in place of
pos.ico and it squawks that there are illegal characters in the path.

Thanks!

Darhl
"Jim Wooley" <ji*************@hotmail.com> wrote in message
news:24*************************@msnews.microsoft. com...
So, as in my example below, when I specify the files to copy and run
this, it tells me that my destination directory already exists. But
it will always exist, it is put in place by the original software
installation and contains sub directories.
Private Sub cmdYes_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles cmdYes.Click

Source = "\files\pos.ico"

Dest = IcmPath & "\ICM\Package"

My.Computer.FileSystem.CopyFile(Source, Dest)

MsgBox("Files copied into " & IcmPath & "\ICM\Package")

End Sub


It appears that you are trying to copy the file to the directory, not into
it. Try to tack on the \pos.ico to the end of your Dest string as follows:
Dest = IcmPath & "\ICM\Package\pos.ico"


Additionally, you may want to take the overload on the CopyFile method
that forces an overwrite:
My.Computer.FileSystem.CopyFile(Source, Dest, True)

Jim Wooley
http://devauthority.com/blogs/jwooley/default.aspx

May 8 '06 #3
> Hi Jim,

That did work, but I really don't want to have to specify the files.
I'm just using pos.ico as a test bed, but in reality, there may be up
to 10 files in the \files directory on the CD that need to be copied
into the IcmPath\ICM\Package folder. I want the app to find the names
on it's own, not specify them. Is this possible? I've tried putting
*.* in place of pos.ico and it squawks that there are illegal
characters in the path.


I don't believe you can use a wild card search, but you could try modifying
the following to suit your purposes:

For Each f As String In System.IO.Directory.GetFiles("c:\windows")
If System.IO.Path.GetExtension(f) = ".ico" Then
System.IO.File.Move(f, DestPath & System.IO.Path.GetFileName(f))
End If
Next

Jim Wooley
http://devauthority.com/blogs/jwooley/default.aspx
May 8 '06 #4
That looks like it may be what I want...can the "System.IO.File.Move" be
"System.IO.File.Copy"? Since it will ultimately be coming off a CD, the
files won't be moveable...

Thanks again!

Darhl
"Jim Wooley" <ji*************@hotmail.com> wrote in message
news:24*************************@msnews.microsoft. com...
Hi Jim,

That did work, but I really don't want to have to specify the files.
I'm just using pos.ico as a test bed, but in reality, there may be up
to 10 files in the \files directory on the CD that need to be copied
into the IcmPath\ICM\Package folder. I want the app to find the names
on it's own, not specify them. Is this possible? I've tried putting
*.* in place of pos.ico and it squawks that there are illegal
characters in the path.


I don't believe you can use a wild card search, but you could try
modifying the following to suit your purposes:

For Each f As String In System.IO.Directory.GetFiles("c:\windows")
If System.IO.Path.GetExtension(f) = ".ico" Then
System.IO.File.Move(f, DestPath &
System.IO.Path.GetFileName(f))
End If
Next

Jim Wooley
http://devauthority.com/blogs/jwooley/default.aspx

May 8 '06 #5
> That looks like it may be what I want...can the "System.IO.File.Move"
be "System.IO.File.Copy"? Since it will ultimately be coming off a
CD, the files won't be moveable...


Should be able to. Just watch out for the read only flag. Files on the CD
are automatically tagged as read only which sometimes causes problems down
the road when copying.

Jim Wooley
http://devauthority.com/blogs/jwooley/default.aspx
May 8 '06 #6
Thanks for the suggestions, it works great now. I'll build it and burn it
to CD with the accessory files and see what happens.

Thanks again!

Darhl
"Jim Wooley" <ji*************@hotmail.com> wrote in message
news:24*************************@msnews.microsoft. com...
That looks like it may be what I want...can the "System.IO.File.Move"
be "System.IO.File.Copy"? Since it will ultimately be coming off a
CD, the files won't be moveable...


Should be able to. Just watch out for the read only flag. Files on the CD
are automatically tagged as read only which sometimes causes problems down
the road when copying.

Jim Wooley
http://devauthority.com/blogs/jwooley/default.aspx

May 8 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Paul | last post by:
Hi, VB.NET is saying the file I am creating is in use by another process and won't complete its task of moving the file to the specified destination folder. Here is my code (the main bit...
5
by: stand__sure | last post by:
I had occasion tonight to write an installer class that changed something in a config file tonight (I had never had a need to do it, but happened upon a "How To" article that explained it in terms...
2
by: Eric Falsken | last post by:
Eric Falsken <eric@db4o.com> wrote on 04 Dec 2005: > craigkenisston@hotmail.com wrote on 19 Nov 2005: > >> I'm working in the migration of an asp.net application in 1.1 to 2.0. >> I'm new to...
5
by: vul | last post by:
I'm developing Windows Service which is going to listen MS Fax service events and update the database when Fax Job changed its status. I need to read OutboxLOG.txt which is used by MS Fax service....
1
by: Mark | last post by:
The new file based web server that comes with Visual Studio 2005 allows you to develop and debug an ASP.NET on a remote computer rather than having to rely on IIS. Assuming you've got decent LAN...
2
by: Gighen | last post by:
Is there some method to copy files from a folder to another using jolly characters using VB 2005? I know that File.Copy(String,String) doesn't support this feature. thnks in advance Gighen
14
by: Rob Meade | last post by:
Hi all, I'm working on a project where there are just under 1300 course files, these are HTML files - my problem is that I need to do more with the content of these pages - and the thought of...
9
by: fniles | last post by:
I would like to copy a table(s) from SQL Server 2005 to a CVS file and vice versa. I was thinking to use the BCP command line utility, but I have a few questions: 1. The machine where I am...
3
by: Dean Slindee | last post by:
Using VS2005, I am deploying a WinForm application with ClickOnce. The project contains a ReportViewer2005 control, so there is a prerequisite for the ReportViewer2005.dll. The ReportViewer.dll...
5
by: Author | last post by:
This may sound like a silly question. I rarely do console or windows form applications. In a console application, I have an XML configuration file. I place it under my application root. In...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.