|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
File copy VB Exp 2005now. 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
Show quote
Hide quote
> So, as in my example below, when I specify the files to copy and run It appears that you are trying to copy the file to the directory, not into > 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. 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 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 Show quoteHide quote "Jim Wooley" <jimNOSPAMwooley@hotmail.com> wrote in message news:24f81e8eb7a98c840b8688006ae@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 > > > Hi Jim, I don't believe you can use a wild card search, but you could try modifying > > 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. 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 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 Show quoteHide quote "Jim Wooley" <jimNOSPAMwooley@hotmail.com> wrote in message news:24f81e8eb8268c840c009f62e68@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 > > > That looks like it may be what I want...can the "System.IO.File.Move" Should be able to. Just watch out for the read only flag. Files on the CD > be "System.IO.File.Copy"? Since it will ultimately be coming off a > CD, the files won't be moveable... are automatically tagged as read only which sometimes causes problems down the road when copying. Jim Wooley http://devauthority.com/blogs/jwooley/default.aspx 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 Show quoteHide quote "Jim Wooley" <jimNOSPAMwooley@hotmail.com> wrote in message news:24f81e8eb87e8c840cc58adc8b3@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 > >
Fat client - Server: Which technology?
Alternative to OpenFileDialog? umanaged code - array error Thread Sync Queue Problem Regular expression rejecting invalid files Outlook Add In is not shown for 1 user... Serial Port - How To Use "Invoke" On The Second Thread UBound behaviour Option Strict On does not cause compilation error Ignoring mouse event from contained controls |
|||||||||||||||||||||||