473,231 Members | 1,821 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,231 software developers and data experts.

how to move checkeditems file in listbox to a folder?

hi. im actually making a desktop cleaner that can move the files and icons to a folder inside the listview box.
i can make the listview box filled with files contains at the desktop
and i can make a new folder which suppose to be move the files on that folder

i have 3 problems:

1. is how to get last access time of the FILE and put it column2 of the listview

2. i want to view that are unused icon and document last week, 2weeks, 1month and 2months by selecting at the combobox

3. how to move checkeditems file in listbox to a folder?


i've been researching for 2 days and not posting a topic and now im frustrated
help me.. thanks in advance.

Expand|Select|Wrap|Line Numbers
  1. Imports System.Runtime.InteropServices 'For APIs
  2. Imports System.IO 'Import System.IO For File Operations 
  3. Imports Microsoft.Win32 'The Registry stuff
  4. Imports System.Windows.Forms.Application
  5. Imports System
  6.  
  7.  
  8.  
  9. 'TO view files inside the listbox
  10.  
  11. Public Class Form1
  12.  
  13.     Private Filenames() As String
  14.  
  15.     Private Sub LoadFilenames()
  16.  
  17.         Dim Desktop As String = My.Computer.FileSystem.SpecialDirectories.Desktop.ToString()
  18.         Dim FilePath As String 
  19.         Dim NumFiles As Integer 
  20.         Dim TruncName As String 
  21.  
  22.         For Each FilePath In Directory.GetFiles(Desktop)
  23.  
  24.             TruncName = FilePath.Substring(FilePath.LastIndexOf("\") + 1) 'Remove Path From Name
  25.  
  26.  
  27.             ListView1.Items.Add(TruncName)
  28.  
  29.  
  30.             ReDim Preserve ScreenNames(NumFiles) 
  31.  
  32.             FileNames(NumFiles) = FilePath 
  33.  
  34.             NumFiles = NumFiles + 1 'Increment File Count
  35.  
  36.  
  37.  
  38.         Next
  39.  
  40.     End Sub
  41.  
  42.     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  43.         LoadFilenames()
  44.     End Sub
  45.  
  46.  
  47. TO CREATE A FOLDER ON DESKTOP
  48.  
  49.  Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  50.         Dim Desktop As String = My.Computer.FileSystem.SpecialDirectories.Desktop
  51.  
  52.         If Not My.Computer.FileSystem.DirectoryExists(Desktop & "\Unused Desktop Icon and Documents") Then
  53.         My.Computer.FileSystem.CreateDirectory(Desktop & "\Unused Desktop Icon and Documents")
  54.           End If
  55.  
  56.  
  57.         With Me.ListView1
  58.             For i As Integer = 0 To .CheckedItems.Count - 1
  59.  
  60.                 .Items.Remove(.CheckedItems(0))
  61.  
  62.             Next i
  63.         End With
  64.  
  65.         ' If di.Exists Then
  66.         ' Indicate that it already exists.
  67.         ' MsgBox("That path exists already.")
  68.         ' Else
  69.         ' Try to create the directory.
  70.         ' di.Create()
  71.  
  72.         '  End If
  73.  
  74.         'TextBox1.Text = di.FullName
  75.  
  76.  
  77.     End Sub
  78.  
  79.  
  80.  
Jun 25 '08 #1
4 1631
Curtis Rutland
3,256 Expert 2GB
You should look into FileInfo and DirectoryInfo. I've found them much more useful than the File and Directory objects.
Jun 25 '08 #2
You should look into FileInfo and DirectoryInfo. I've found them much more useful than the File and Directory objects.
what's the difference of fileinfo and directoryinfo between file and directory? when i'm typing fileinfo the only extension .equals .reference equals. pls help. need some sample codes if any. thanks.
Jun 25 '08 #3
Curtis Rutland
3,256 Expert 2GB
what's the difference of fileinfo and directoryinfo between file and directory? when i'm typing fileinfo the only extension .equals .reference equals. pls help. need some sample codes if any. thanks.
Here are a few very quick samples of what you can do with the FileInfo and DirectoryInfo classes:
Expand|Select|Wrap|Line Numbers
  1.         Dim d As New System.IO.DirectoryInfo("path")
  2.         Dim fArray As System.IO.FileInfo()
  3.         'gets all files with/without filter
  4.         fArray = d.GetFiles("*.txt")
  5.  
  6.         Dim f As New System.IO.FileInfo("filePath")
  7.         Dim lastAccesed As DateTime
  8.         'last accessed time 
  9.         lastAccesed = f.LastAccessTime
  10.  
Jun 25 '08 #4
Here are a few very quick samples of what you can do with the FileInfo and DirectoryInfo classes:
Expand|Select|Wrap|Line Numbers
  1.         Dim d As New System.IO.DirectoryInfo("path")
  2.         Dim fArray As System.IO.FileInfo()
  3.         'gets all files with/without filter
  4.         fArray = d.GetFiles("*.txt")
  5.  
  6.         Dim f As New System.IO.FileInfo("filePath")
  7.         Dim lastAccesed As DateTime
  8.         'last accessed time 
  9.         lastAccesed = f.LastAccessTime
  10.  
how about #3? when i checked some files in the listview1. when i hit the button the file that i checked will be move to another folder? is it possible to store data when it checked? thanks for helping me.
Jun 26 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Eric Kiernan | last post by:
I have a form that I previously created and put a number of text box controls on. Everything previously worked. Now when I enter the form ( in design mode ), I can't move any of the controls to...
1
by: bmgz | last post by:
I am have made a simple script that moves all desktop clutter (ie files that are not *.lnk) to a specified folder eg. c:\myhome\mydocs\desktopdebris\2003-12-16 ...
6
by: Daniel Bickett | last post by:
Hello, I'm writing an application in my pastime that moves files around to achieve various ends -- the specifics aren't particularly important. The shutil module was chosen as the means simply...
8
by: Mr. B | last post by:
I'm writing an app where I'm trying to look for and List all specific file 'types' found. So I point to a specific start top level Folder... and I want to drill down through ALL sub folders to...
7
by: Byron | last post by:
I'm looking for a way to deny a move from the current listbox item. For instance, if the user is editing the record associated with the current listbox item I want to deny a move within the...
3
by: rn5a | last post by:
I am not very sure whether I should have continued with my earlier thread or started a new thread whose subject matter was somewhat similar to the subject matter in this thread. Anyway after much...
3
by: jaeden99 | last post by:
I was wandering if nyone has a script to move files older than x days old? i've seen several to delete, but I don't want to delete. I would like to create a backup of the files first verify with...
3
by: igglepiggle | last post by:
I have developed a form that runs a folder browser dialog and then details all filenames within the chosen folder in a listbox. Currently the filenames populate a 1-D array before they are written...
7
Curtis Rutland
by: Curtis Rutland | last post by:
Building A Silverlight (2.0) Multi-File Uploader All source code is C#. VB.NET source is coming soon. Note: This project requires Visual Studio 2008 SP1 or Visual Web Developer 2008 SP1 and...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.