how to move checkeditems file in listbox to a folder?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mikkoO8
    New Member
    • Jan 2008
    • 3

    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.

    Code:
    Imports System.Runtime.InteropServices 'For APIs
    Imports System.IO 'Import System.IO For File Operations 
    Imports Microsoft.Win32 'The Registry stuff
    Imports System.Windows.Forms.Application
    Imports System
    
    
    
    'TO view files inside the listbox
    
    Public Class Form1
    
        Private Filenames() As String
    
        Private Sub LoadFilenames()
    
            Dim Desktop As String = My.Computer.FileSystem.SpecialDirectories.Desktop.ToString()
            Dim FilePath As String 
            Dim NumFiles As Integer 
            Dim TruncName As String 
    
            For Each FilePath In Directory.GetFiles(Desktop)
    
                TruncName = FilePath.Substring(FilePath.LastIndexOf("\") + 1) 'Remove Path From Name
    
         
                ListView1.Items.Add(TruncName)
    
            
                ReDim Preserve ScreenNames(NumFiles) 
    
                FileNames(NumFiles) = FilePath 
    
                NumFiles = NumFiles + 1 'Increment File Count
    
     
    
            Next
    
        End Sub
    
        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            LoadFilenames()
        End Sub
    
    
    TO CREATE A FOLDER ON DESKTOP
    
     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            Dim Desktop As String = My.Computer.FileSystem.SpecialDirectories.Desktop
    
            If Not My.Computer.FileSystem.DirectoryExists(Desktop & "\Unused Desktop Icon and Documents") Then
            My.Computer.FileSystem.CreateDirectory(Desktop & "\Unused Desktop Icon and Documents")
              End If
    
            
    	    With Me.ListView1
                For i As Integer = 0 To .CheckedItems.Count - 1
    
                    .Items.Remove(.CheckedItems(0))
    
                Next i
            End With
    
            ' If di.Exists Then
            ' Indicate that it already exists.
            ' MsgBox("That path exists already.")
            ' Else
            ' Try to create the directory.
            ' di.Create()
    
            '  End If
    
            'TextBox1.Text = di.FullName
    
    
        End Sub
  • Curtis Rutland
    Recognized Expert Specialist
    • Apr 2008
    • 3264

    #2
    You should look into FileInfo and DirectoryInfo. I've found them much more useful than the File and Directory objects.

    Comment

    • mikkoO8
      New Member
      • Jan 2008
      • 3

      #3
      Originally posted by insertAlias
      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.

      Comment

      • Curtis Rutland
        Recognized Expert Specialist
        • Apr 2008
        • 3264

        #4
        Originally posted by mikkoO8
        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:
        Code:
        		Dim d As New System.IO.DirectoryInfo("path")
        		Dim fArray As System.IO.FileInfo()
        		'gets all files with/without filter
        		fArray = d.GetFiles("*.txt")
        
        		Dim f As New System.IO.FileInfo("filePath")
        		Dim lastAccesed As DateTime
        		'last accessed time 
        		lastAccesed = f.LastAccessTime

        Comment

        • mikkoO8
          New Member
          • Jan 2008
          • 3

          #5
          Originally posted by insertAlias
          Here are a few very quick samples of what you can do with the FileInfo and DirectoryInfo classes:
          Code:
          		Dim d As New System.IO.DirectoryInfo("path")
          		Dim fArray As System.IO.FileInfo()
          		'gets all files with/without filter
          		fArray = d.GetFiles("*.txt")
          
          		Dim f As New System.IO.FileInfo("filePath")
          		Dim lastAccesed As DateTime
          		'last accessed time 
          		lastAccesed = f.LastAccessTime
          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.

          Comment

          Working...