Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Register Tags Active Topics RSS Search Mark Forums Read

Sponsored Links



Visual Studio 2010: Moving files to the trash

Software Development


Reply
 
Thread Tools Search this Thread
  #1  
Old 01-12-2010
Member
 
Join Date: Sep 2010
Posts: 26
Visual Studio 2010: Moving files to the trash
  

Hello everyone, since I could not find the old post, so I asked them the question ... now I write it here XD I hope is not a problem. this is the code to delete temporary files:
Code:
Dim size As Long
         As Long Dim sizeTemp
         Dim inf As System.IO.FileInfo
         Dim con As Integer = 0 Dim totLen As Double = 0

         For Each foundFile As String In My.Computer.FileSystem.GetFiles (My.Computer.FileSystem.SpecialDirectories.Temp, _
                                                                         Microsoft.VisualBasic.FileIO.SearchOption.SearchAllSubDirectories, "*.*")

             count = count + 1
             Try
                 info = New System.IO.FileInfo (foundFile)
                 sizeTemp = info.Length
                 System.IO.File.Delete (foundFile)
                 size + = sizeTemp
                 ListBox.Items.Add (foundFile)
             Catch ept As Exception
             Finally
                 info = Nothing
             End Try
         Next
But if I wanted to just move them to the trash? I tried to change but it gives me error .. like it? I am sure that someone over there must have some solutions for this. Please help me out.

Reply With Quote
  #2  
Old 01-12-2010
Member
 
Join Date: Oct 2008
Posts: 105
Re: Visual Studio 2010: Moving files to the trash

I think that you should add some more in the coding while integrating. Try the following code, which can be useful for moving the files in trash.
Code:
MyComputer.FileIO.DeleteFile (foundFile, FileIO.UIOption, FileIO.OnlyErrorLogs.RecycleOption.SendToRecycleBin)
Even after implementing this code, if you are getting some error then provide more details of the error message along with the modified code. Sure there would be someone for your help (if I am not able to).
Reply With Quote
  #3  
Old 01-12-2010
Member
 
Join Date: Sep 2010
Posts: 26
Re: Visual Studio 2010: Moving files to the trash

The code is there, just that I would turn to "permanently delete files" in "move files to trash". And as the delete command is in the try, I do not know how. I tried! really!! Only that wherever I put the move command and not for the delete, it gives me an error, sometimes the same at different times ... but I do not know where to put it. So please give some more details about it. Since, I have to submit it sooner, I am requesting you all to help me fast.
Reply With Quote
  #4  
Old 01-12-2010
Member
 
Join Date: May 2008
Posts: 255
Re: Visual Studio 2010: Moving files to the trash

But sorry, that code you wrote yourself? Try if you hide the exception that occurs inside a little bad, you can always remove the Try or run the code line by line and see what happens. VS debugging systems are many, I do not see what the problem is: you can put a breakpoint and then execute the code line by line to see where it stops running ... At that point you will come to know where exactly the problem is residing.
Reply With Quote
  #5  
Old 01-12-2010
Member
 
Join Date: Sep 2010
Posts: 26
Re: Visual Studio 2010: Moving files to the trash

If I delete and try to move I put the code directly into the trash, it works, but I would try to stay on, because with it, when it finds files in use, skip them without giving errors. In the end I need to try this and to show the files in listview. Finally, it gives me error after start debugging, but take it from me first, that makes me not even start debugging, and tells me that I must first correct the errors. The following is the code now :
Code:
For Each foundFile As String In My.Computer.FileSystem.GetFiles (My.Computer.FileSystem.SpecialDirectories.Temp, _
                                                                         Microsoft.VisualBasic.FileIO.SearchOption.SearchAllSubDirectories, "*.*")

             count = count + 1
             Try
                 info = New System.IO.FileInfo (foundFile, FileIO.UIOption.OnlyErrorLogs, FileIO.RecycleOption.SendToRecycleBin)
                 sizeTemp = inf.Length
                 System.IO.File.Delete (foundFile)
                 size + = sizeTemp
                 ListBox.Items.Add (foundFile)
             Catch exp As Exception
             Finally
                 inf = Nothing
             End Try
         Next
Here tells me: Overload resolution failed because no 'New' accepts this number of subjects available.
While trying another way :
Code:
For Each foundFile As String In My.Computer.FileSystem.GetFiles (My.Computer.FileSystem.SpecialDirectories.Temp, _
                                                                         Microsoft.VisualBasic.FileIO.SearchOption.SearchAllSubDirectories, "*.*")

             count = count + 1
             Try
                 inf = New System.IO.FileInfo (foundFile)
                 sizeTemp = info.Length
                 System.IO.File.Delete (foundFile, FileIO.UIOption.OnlyErrorLogs, FileIO.RecycleOption.SendToRecycleBin)
                 size + = sizeTemp
                 ListBox.Items.Add (foundFile)
             Catch exp As Exception
             Finally
                 inf = Nothing
             End Try
         Next
but here I get this: Too many arguments to 'Public Shared Sub Delete (path As String)'.. I'm not understanding anything! I want to integrate the command to move files to the trash directly into this and I do not want to try a different code.
Reply With Quote
  #6  
Old 01-12-2010
Member
 
Join Date: Apr 2009
Posts: 78
Re: Visual Studio 2010: Moving files to the trash

The line posted need to move the file to the trash, it is obviously putting in place of the similar line in the original code deletes the file permanently. Does not even fit, to make things easier it has also taken the trouble to insert the variable used in your code. You just do a nice cut and paste, that's all. If you can not do this simple task is evident that you have not tried at all to understand the meaning of the original block of code, but are simply trying to run it with a hammer.
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Visual Studio 2010: Moving files to the trash"
Thread Thread Starter Forum Replies Last Post
Visual Studio 2010: features and changes compared to Visual Studio 2008 BinDs14 Guides & Tutorials 2 16-02-2011 02:49 PM
How to run Silverlight 4 in Visual Studio 2010 wllwnn Tips & Tweaks 1 05-08-2010 02:32 AM
Can't install visual studio 2010 DarkShadow Windows Software 4 18-02-2010 09:13 PM
Compare Visual Studio 2010 and Visual Web Developer Express Zacharia Software Development 5 28-01-2010 04:27 AM
Microsoft Visual Studio 2010 kelfro Software Development 1 21-01-2009 06:40 PM


All times are GMT +5.5. The time now is 12:54 PM.