|
| ||||||||||
| Tags: code, debug, error message, fileio, uioption, visual studio 2010 |
![]() |
| | Thread Tools | Search this Thread |
|
#1
| |||
| |||
| Visual Studio 2010: Moving files to the trash
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 ![]() |
|
#2
| |||
| |||
| 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) |
|
#3
| |||
| |||
| 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. ![]() |
|
#4
| ||||
| ||||
| 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. |
|
#5
| |||
| |||
| 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 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 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. |
|
#6
| ||||
| ||||
| 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. ![]() |
![]() |
|
| Thread Tools | Search this Thread |
| |
Similar Threads for: "Visual Studio 2010: Moving files to the trash" | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Visual Studio 2010 and SilverLight 3. | Licka Boy | Windows Software | 5 | 19-04-2011 10:35 AM |
| Visual Studio 2010: features and changes compared to Visual Studio 2008 | BinDs14 | Guides & Tutorials | 2 | 16-02-2011 01:49 PM |
| How to run Silverlight 4 in Visual Studio 2010 | wllwnn | Tips & Tweaks | 1 | 05-08-2010 01:32 AM |
| Can't install visual studio 2010 | DarkShadow | Windows Software | 4 | 18-02-2010 08:13 PM |
| Compare Visual Studio 2010 and Visual Web Developer Express | Zacharia | Software Development | 5 | 28-01-2010 03:27 AM |