Quick question for copying files

For a lil project of mine.

Page 1 of 1

8 Replies - 686 Views - Last Post: 11 May 2010 - 01:09 PM Rate Topic: -----

#1 L14M333  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 07-May 10

Quick question for copying files

Posted 11 May 2010 - 09:23 AM

Hello. im working on a little project for myself in Microsoft Visual Basic 2010 and i want to add an option so that when a user clicks a button it will open a browse directory window where they can select their directory and when they click "Ok" it will copy files into it.. its a basic question i think but im stumped.. heres my code:

Spoiler



I dont know if that is right but i think it is.


Please can someone help me



Thanks

Liam

Is This A Good Question/Topic? 0
  • +

Replies To: Quick question for copying files

#2 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6058
  • View blog
  • Posts: 23,495
  • Joined: 23-August 08

Re: Quick question for copying files

Posted 11 May 2010 - 09:24 AM

Visual Basic 2010 is NOT VB6, it's VB.NET.

Moved.
Was This Post Helpful? 0
  • +
  • -

#3 L14M333  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 07-May 10

Re: Quick question for copying files

Posted 11 May 2010 - 09:37 AM

View PostJackOfAllTrades, on 11 May 2010 - 08:24 AM, said:

Visual Basic 2010 is NOT VB6, it's VB.NET.

Moved.




sorry, didn't realise i was in VB6
Was This Post Helpful? 0
  • +
  • -

#4 _HAWK_  Icon User is offline

  • Master(Of Foo)
  • member icon

Reputation: 1052
  • View blog
  • Posts: 4,076
  • Joined: 02-July 08

Re: Quick question for copying files

Posted 11 May 2010 - 10:12 AM

Something like this:

Imports System.IO 'at the top

Dim fbd As New FolderBrowserDialog
   'set your properties
If fbd.ShowDialog() = DialogResult.OK Then
  Dim destDir As New DirectoryInfo(fbd.SelectedPath)
  Dim sourceDir As New DirectoryInfo("C:\Documents and Settings\Liam\Desktop\v2.0 (W.O Verification)\PatchHelperFiles\")
  For Each file As FileInfo In sourceDir.GetFiles
    file.CopyTo(Path.Combine(destDir.FullName, file.Name))
  Next
End If

Was This Post Helpful? 1
  • +
  • -

#5 L14M333  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 07-May 10

Re: Quick question for copying files

Posted 11 May 2010 - 10:44 AM

View Posthawkvalley1, on 11 May 2010 - 09:12 AM, said:

Something like this:

Imports System.IO 'at the top

Dim fbd As New FolderBrowserDialog
   'set your properties
If fbd.ShowDialog() = DialogResult.OK Then
  Dim destDir As New DirectoryInfo(fbd.SelectedPath)
  Dim sourceDir As New DirectoryInfo("C:\Documents and Settings\Liam\Desktop\v2.0 (W.O Verification)\PatchHelperFiles\")
  For Each file As FileInfo In sourceDir.GetFiles
    file.CopyTo(Path.Combine(destDir.FullName, file.Name))
  Next
End If



Thank you! that helped a lot! just one more thing :D i know it gets the files from "C:\Documents and Settings\Liam\Desktop\v2.0 (W.O Verification)\PatchHelperFiles\" but, if im distributing this program the files will hopefully be embedded into the program. how would i do that? i have read certain things but it all confuses me... if its not too had please can someone explain how i would.


Thanks

Liam
Was This Post Helpful? 0
  • +
  • -

#6 code_junkie83  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 7
  • View blog
  • Posts: 62
  • Joined: 17-June 09

Re: Quick question for copying files

Posted 11 May 2010 - 11:23 AM

What have you read that confuses you? I would think you could access it via Resources, if the files are embedded in the project.
Was This Post Helpful? 0
  • +
  • -

#7 _HAWK_  Icon User is offline

  • Master(Of Foo)
  • member icon

Reputation: 1052
  • View blog
  • Posts: 4,076
  • Joined: 02-July 08

Re: Quick question for copying files

Posted 11 May 2010 - 12:18 PM

If you use just the filename it assumes it's in the executable folder. Where your exe lives, and this converts over just fine after publish.
Was This Post Helpful? 0
  • +
  • -

#8 L14M333  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 07-May 10

Re: Quick question for copying files

Posted 11 May 2010 - 12:21 PM

View Posthawkvalley1, on 11 May 2010 - 11:18 AM, said:

If you use just the filename it assumes it's in the executable folder. Where your exe lives, and this converts over just fine after publish.


Ok. thanks for that... is there a way to embed the files into the exe though? and how would i go about loading them?

Liam
Was This Post Helpful? 0
  • +
  • -

#9 _HAWK_  Icon User is offline

  • Master(Of Foo)
  • member icon

Reputation: 1052
  • View blog
  • Posts: 4,076
  • Joined: 02-July 08

Re: Quick question for copying files

Posted 11 May 2010 - 01:09 PM

If you place the files in the folder holding your exe - the ...\bin\Debug\ then when you build it those files go with it. Then
Dim fi As New FileInfo("yourfilename.txt") will be assessable by this same method, but have a different location path when your debugging.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1