3 Replies - 928 Views - Last Post: 09 June 2011 - 03:36 PM Rate Topic: -----

#1 jayawant  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 21
  • Joined: 10-May 11

in button click event how to export & delete file at a time in vb.

Posted 09 June 2011 - 03:05 PM

Hi,

In windows form in button click event how to export the file in a location select by showdialog & it will be delete permanently at a same time.How can i do this!
because in .net it will produces error "IO Exception was unhandled" or "The process can not access the file because it is used by anather process." .In button click event how to export the file & delete at same time in vb.net windows application.Please give me the links & urls about that issue.

Is This A Good Question/Topic? 0
  • +

Replies To: in button click event how to export & delete file at a time in vb.

#2 trevster344  Icon User is offline

  • The Peasant
  • member icon

Reputation: 224
  • View blog
  • Posts: 1,499
  • Joined: 16-March 11

Re: in button click event how to export & delete file at a time in vb.

Posted 09 June 2011 - 03:08 PM

You want to move a file? or delete it?

If you want to move a file:
Dim File1 as System.IO.File
File1.Move("FILE", "DESTFILE")


This post has been edited by trevster344: 09 June 2011 - 03:13 PM

Was This Post Helpful? 0
  • +
  • -

#3 Ionut  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 385
  • View blog
  • Posts: 1,057
  • Joined: 17-July 10

Re: in button click event how to export & delete file at a time in vb.

Posted 09 June 2011 - 03:13 PM

You should post the code that produces the errors you mention. Basically, any file manipulation in .NET can be done with File class and Directory class
Was This Post Helpful? 0
  • +
  • -

#4 raziel_  Icon User is offline

  • Like a lollipop
  • member icon

Reputation: 464
  • View blog
  • Posts: 4,255
  • Joined: 25-March 09

Re: in button click event how to export & delete file at a time in vb.

Posted 09 June 2011 - 03:36 PM

Is the file big? if so the error is probably because the file is too big and its being copied at the time when you try to delete it. You can bypass this by moving the file as trevster344 suggested. Or because the file is used by other program in this case you should make an endless loop that will catch the exception when trying to delete it and if you succeed deleting it exit the loop

This post has been edited by NoBrain: 09 June 2011 - 03:39 PM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1