Quantcast

Jump to content

» «
Photo

Visual basic 2010 help

5 replies to this topic
ChopTheDog.
  • ChopTheDog.

    War. War never changes.

  • Members
  • Joined: 31 May 2010
  • None

#1

Posted 09 December 2011 - 05:43 PM

CODE

Dim attribute As System.IO.FileAttributes = IO.FileAccess.ReadWrite
System.IO.File.SetAttributes(safold.SelectedPath, attribute)
System.IO.File.Copy(safold.SelectedPath, ListBox1.Items.Item(0), True)
MsgBox("Files copied")


Okay, im trying to copy a file to a folder (safold.selectedpath) and i keep getting a "Access to path [safold's path] denied" as you can see im even editing the files attributes to read and write and i still get this error, the selected path isnt read only either, so whats causing this problem?

K^2
  • K^2

    Vidi Vici Veni

  • Moderator
  • Joined: 14 Apr 2004
  • United-States

#2

Posted 09 December 2011 - 08:50 PM

Two possible causes I can think of. First, the path to copy the file to must contain the file name. It shouldn't be just a path to a folder to which you're copying. Second, if the file exists, File.Copy won't overwrite by default. To allow overwrite, you must call File.Copy(path_to, path_from, True).

OzzySM12
  • OzzySM12

    Hmm...

  • Members
  • Joined: 07 Nov 2004

#3

Posted 10 December 2011 - 01:02 AM

If the files are in system folders such as "Program Files" or "Windows" you may need to run your program as administrator.

ChopTheDog.
  • ChopTheDog.

    War. War never changes.

  • Members
  • Joined: 31 May 2010
  • None

#4

Posted 10 December 2011 - 04:46 PM

Thanks for the reply dudes, given up on Visual basic as its a time waster icon13.gif
Started to learn c++ using "cprogramming.com"

Im currently using codeblocks as my debugger, cause vc++ is too complicated for me suicidal.gif

Swoorup
  • Swoorup

    innovator

  • Members
  • Joined: 28 Oct 2008

#5

Posted 11 December 2011 - 04:21 PM

VB is still a fast way to make Window based apps. smile.gif
And I think you meant to say Codeblocks as IDE ( Integrated Development Environment) ?

nightwalker83
  • nightwalker83

    Don't mind me

  • Members
  • Joined: 10 Oct 2004

#6

Posted 13 December 2011 - 06:02 AM

QUOTE (The_Sorrow @ Sunday, Dec 11 2011, 03:16)
Thanks for the reply dudes, given up on Visual basic as its a time waster icon13.gif
Started to learn c++ using "cprogramming.com"

Im currently using codeblocks as my debugger, cause vc++ is too complicated for me suicidal.gif

How are you finding C++?




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users